2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Omar Tarabai
23 * Plugin API for the peerstore database backend
25 * @defgroup peerstore-plugin Peer Store service plugin API
26 * Plugin API for the peerstore database backend
29 #ifndef GNUNET_PEERSTORE_PLUGIN_H
30 #define GNUNET_PEERSTORE_PLUGIN_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_peerstore_service.h"
38 #if 0 /* keep Emacsens' auto-indent happy */
45 * @brief struct returned by the initialization function of the plugin
47 struct GNUNET_PEERSTORE_PluginFunctions
51 * Closure to pass to all plugin functions.
56 * Store a record in the peerstore.
57 * Key is the combination of sub system and peer identity.
58 * One key can store multiple values.
60 * @param cls closure (internal context for the plugin)
61 * @param sub_system name of the GNUnet sub system responsible
62 * @param peer peer identity
63 * @param value value to be stored
64 * @param size size of value to be stored
65 * @param expiry absolute time after which the record is (possibly) deleted
66 * @param options options related to the store operation
67 * @param cont continuation called when record is stored
68 * @param cont_cls continuation closure
69 * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
72 (*store_record) (void *cls,
73 const char *sub_system,
74 const struct GNUNET_PeerIdentity *peer,
78 struct GNUNET_TIME_Absolute expiry,
79 enum GNUNET_PEERSTORE_StoreOption options,
80 GNUNET_PEERSTORE_Continuation cont,
84 * Iterate over the records given an optional peer id
87 * @param cls closure (internal context for the plugin)
88 * @param sub_system name of sub system
89 * @param peer Peer identity (can be NULL)
90 * @param key entry key string (can be NULL)
91 * @param iter function to call asynchronously with the results, terminated
93 * @param iter_cls closure for @a iter
94 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
98 (*iterate_records) (void *cls,
99 const char *sub_system,
100 const struct GNUNET_PeerIdentity *peer,
102 GNUNET_PEERSTORE_Processor iter,
106 * Delete expired records (expiry < now)
108 * @param cls closure (internal context for the plugin)
109 * @param now time to use as reference
110 * @param cont continuation called with the number of records expired
111 * @param cont_cls continuation closure
112 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
116 (*expire_records) (void *cls,
117 struct GNUNET_TIME_Absolute now,
118 GNUNET_PEERSTORE_Continuation cont,
124 #if 0 /* keep Emacsens' auto-indent happy */
133 /** @} */ /* end of group */