gnunet_peerstore_plugin.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2012, 2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet 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 GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Omar Tarabai
  18. *
  19. * @file
  20. * Plugin API for the peerstore database backend
  21. *
  22. * @defgroup peerstore-plugin Peer Store service plugin API
  23. * Plugin API for the peerstore database backend
  24. * @{
  25. */
  26. #ifndef GNUNET_PEERSTORE_PLUGIN_H
  27. #define GNUNET_PEERSTORE_PLUGIN_H
  28. #include "gnunet_util_lib.h"
  29. #include "gnunet_peerstore_service.h"
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #if 0 /* keep Emacsens' auto-indent happy */
  34. }
  35. #endif
  36. #endif
  37. /**
  38. * @brief struct returned by the initialization function of the plugin
  39. */
  40. struct GNUNET_PEERSTORE_PluginFunctions
  41. {
  42. /**
  43. * Closure to pass to all plugin functions.
  44. */
  45. void *cls;
  46. /**
  47. * Store a record in the peerstore.
  48. * Key is the combination of sub system and peer identity.
  49. * One key can store multiple values.
  50. *
  51. * @param cls closure (internal context for the plugin)
  52. * @param sub_system name of the GNUnet sub system responsible
  53. * @param peer peer identity
  54. * @param value value to be stored
  55. * @param size size of value to be stored
  56. * @param expiry absolute time after which the record is (possibly) deleted
  57. * @param options options related to the store operation
  58. * @param cont continuation called when record is stored
  59. * @param cont_cls continuation closure
  60. * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
  61. */
  62. int
  63. (*store_record) (void *cls,
  64. const char *sub_system,
  65. const struct GNUNET_PeerIdentity *peer,
  66. const char *key,
  67. const void *value,
  68. size_t size,
  69. struct GNUNET_TIME_Absolute expiry,
  70. enum GNUNET_PEERSTORE_StoreOption options,
  71. GNUNET_PEERSTORE_Continuation cont,
  72. void *cont_cls);
  73. /**
  74. * Iterate over the records given an optional peer id
  75. * and/or key.
  76. *
  77. * @param cls closure (internal context for the plugin)
  78. * @param sub_system name of sub system
  79. * @param peer Peer identity (can be NULL)
  80. * @param key entry key string (can be NULL)
  81. * @param iter function to call asynchronously with the results, terminated
  82. * by a NULL result
  83. * @param iter_cls closure for @a iter
  84. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
  85. * called
  86. */
  87. int
  88. (*iterate_records) (void *cls,
  89. const char *sub_system,
  90. const struct GNUNET_PeerIdentity *peer,
  91. const char *key,
  92. GNUNET_PEERSTORE_Processor iter,
  93. void *iter_cls);
  94. /**
  95. * Delete expired records (expiry < now)
  96. *
  97. * @param cls closure (internal context for the plugin)
  98. * @param now time to use as reference
  99. * @param cont continuation called with the number of records expired
  100. * @param cont_cls continuation closure
  101. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
  102. * called
  103. */
  104. int
  105. (*expire_records) (void *cls,
  106. struct GNUNET_TIME_Absolute now,
  107. GNUNET_PEERSTORE_Continuation cont,
  108. void *cont_cls);
  109. };
  110. #if 0 /* keep Emacsens' auto-indent happy */
  111. {
  112. #endif
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif
  117. /** @} */ /* end of group */