rehash_dht.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* rehash --- a decentralised hash<->hash store
  2. Copyright © 2020 Maxime Devos <maxime.devos@student.kuleuven.be>
  3. This file is part of rehash.
  4. rehash is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or (at
  7. your option) any later version.
  8. rehash is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with rehash. If not, see <http://www.gnu.org/licenses/>. */
  14. /**
  15. * @brief Searching for / inserting hashes in the DHT, without any caching
  16. * @author Maxime Devos
  17. *
  18. * Basically a rather thin wrapper around GNUNET_DHT_put
  19. * and GNUNET_DHT_get_start nicely documenting how to
  20. * encode / decode keys and values.
  21. */
  22. #ifndef REHASH_DHT_H
  23. #define REHASH_DHT_H
  24. #include <gnunet/gnunet_dht_service.h>
  25. #include "rehash_types.h"
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #if 0
  30. }
  31. #endif
  32. #endif
  33. /**
  34. * Insert a hash -> hash mapping into the DHT
  35. *
  36. * @param handle handle to DHT service
  37. * @param key the key to store under, computed with
  38. * REHASH_obfuscated_query_from_hash
  39. * @param desired_replication_level see GNUNET_DHT_put
  40. * @param options see GNUNET_DHT_put
  41. * @param size number of bytes in @a data
  42. * @param data the data to store, computed with
  43. * REHASH_data_for_mapping
  44. * @param exp see GNUNET_DHT_put
  45. * @param cont see GNUNET_DHT_put
  46. * @param cont_cls see GNUNET_DHT_put
  47. * @return handle see GNUNET_DHT_PUT
  48. */
  49. struct GNUNET_DHT_PutHandle *
  50. REHASH_dht_put (struct GNUNET_DHT_Handle *handle,
  51. const struct GNUNET_HashCode *key,
  52. uint32_t desired_replication_level,
  53. enum GNUNET_DHT_RouteOption options,
  54. size_t size,
  55. const void *data,
  56. struct GNUNET_TIME_Absolute exp,
  57. GNUNET_SCHEDULER_TaskCallback cont,
  58. void *cont_cls);
  59. /** Like GNUNET_DHT_get_start, but specialised to hash -> has mappings
  60. * and with less arguments.
  61. *
  62. * @param handle see GNUNET_DHT_get_start
  63. * @param key the key to look up, computed with
  64. * REHASH_obfuscated_query_from_hash
  65. * @param desired_replication_level see GNUNET_DHT_get_start
  66. * @param options see GNUNET_DHT_get_start
  67. * @param iter see GNUNET_DHT_get_start, decode data with
  68. * REHASH_mapping_for_data
  69. * @param iter_cls see GNUNET_DHT_get_start
  70. * @return handle see GNUNET_DHT_get_start
  71. */
  72. struct GNUNET_DHT_GetHandle *
  73. REHASH_dht_get_start (struct GNUNET_DHT_Handle *handle,
  74. const struct GNUNET_HashCode *key,
  75. uint32_t desired_replication_level,
  76. enum GNUNET_DHT_RouteOption options,
  77. GNUNET_DHT_GetIterator iter,
  78. void *iter_cls);
  79. #if 0
  80. {
  81. #endif
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif