2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_psycstore_service.h
23 * @brief PSYCstore service; implements persistent storage for the PSYC service
25 * @author Christian Grothoff
27 #ifndef GNUNET_PSYCSTORE_SERVICE_H
28 #define GNUNET_PSYCSTORE_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_util_lib.h"
41 * Version number of GNUnet PSYCstore API.
43 #define GNUNET_PSYCSTORE_VERSION 0x00000000
46 * Handle for a PSYCstore
48 struct GNUNET_PSYCSTORE_Handle;
52 * Connect to the PSYCstore service.
54 * @param cfg Configuration to use.
56 * @return Handle for the connecton.
58 struct GNUNET_PSYCSTORE_Handle *
59 GNUNET_PSYCSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
63 * Disconnect from the PSYCstore service.
65 * @param h Handle for the connection.
68 GNUNET_PSYCSTORE_disconnect (struct GNUNET_PSYCSTORE_Handle *h);
72 * Handle for an operation on the PSYCSTORE (useful to cancel the operation).
74 struct GNUNET_PSYCSTORE_OperationHandle;
78 * Function called with the result of an asynchronous operation.
80 * @param result #GNUNET_SYSERR on error,
81 * #GNUNET_YES on success or if the peer was a member,
82 * #GNUNET_NO if the peer was not a member
84 typedef void (*GNUNET_PSYCSTORE_ContinuationCallback)(void *cls,
88 * Store join/leave events for a PSYC channel in order to be able to answer
89 * membership test queries later.
91 * @param h Handle for the PSYCstore.
92 * @param channel_id ID of the channel where the event happened.
93 * @param message_id ID of the message in which this event was announced.
94 * @param peer Identity of joining/leaving peer.
95 * @param did_join #GNUNET_YES on join, #GNUNET_NO on leave.
96 * @param ccb Callback to call with the result of the storage operation.
97 * @param ccb_cls Closure for the callback.
99 * @return Operation handle that can be used to cancel the operation.
101 struct GNUNET_PSYCSTORE_OperationHandle *
102 GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
103 const struct GNUNET_HashCode *channel_id,
105 const struct GNUNET_PeerIdentity *peer,
107 GNUNET_PSYCSTORE_ContinuationCallback ccb,
112 * Test if a peer was a member of the channel when the message with the
113 * specified ID was sent to the channel.
115 * This is useful in case of retransmissions to check if the peer was authorized
116 * to see the requested message.
118 * @param h Handle for the PSYCstore.
119 * @param channel_id The channel we are interested in.
120 * @param message_id Message ID to check.
121 * @param peer Peer whose membership to check.
122 * @param ccb Callback to call with the test result.
123 * @param ccb_cls Closure for the callback.
125 * @return Operation handle that can be used to cancel the operation.
127 struct GNUNET_PSYCSTORE_OperationHandle *
128 GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
129 const struct GNUNET_HashCode *channel_id,
131 const struct GNUNET_PeerIdentity *peer,
132 GNUNET_PSYCSTORE_ContinuationCallback ccb,
137 * Store a message sent to a channel.
139 * @param h Handle for the PSYCstore.
140 * @param channel_id The channel the message belongs to.
141 * @param message_id Message ID to store.
142 * @param ccb Callback to call with the result of the operation.
143 * @param ccb_cls Closure for the callback.
145 * @return Handle that can be used to cancel the operation.
147 struct GNUNET_PSYCSTORE_OperationHandle *
148 GNUNET_PSYCSTORE_message_store (struct GNUNET_PSYCSTORE_Handle *h,
149 const struct GNUNET_HashCode *channel_id,
150 const struct GNUNET_MULTICAST_MessageHeader *message,
151 GNUNET_PSYCSTORE_ContinuationCallback ccb,
156 * Function called with the result of a GNUNET_PSYCSTORE_message_get() call.
158 * @param cls Closure.
159 * @param message_id ID of the message.
160 * @param message The retrieved message.
162 typedef void (*GNUNET_PSYCSTORE_MessageResultCallback)(void *cls,
164 const struct GNUNET_MULTICAST_MessageHeader *message);
168 * Retrieve a message by ID.
170 * @param h Handle for the PSYCstore.
171 * @param channel_id The channel we are interested in.
172 * @param message_id Message ID to check.
173 * @param rcb Callback to call with the result of the operation.
174 * @param rcb_cls Closure for the callback.
176 * @return Handle that can be used to cancel the operation.
178 struct GNUNET_PSYCSTORE_OperationHandle *
179 GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
180 const struct GNUNET_HashCode *channel_id,
182 GNUNET_PSYCSTORE_MessageResultCallback rcb,
187 * Get latest message sent to a channel.
189 * @param h Handle for the PSYCstore.
190 * @param channel_id The channel we are interested in.
191 * @param rcb Callback to call with the result of the operation.
192 * @param rcb_cls Closure for the callback.
194 * @return Handle that can be used to cancel the operation.
196 struct GNUNET_PSYCSTORE_OperationHandle *
197 GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
198 const struct GNUNET_HashCode *channel_id,
199 GNUNET_PSYCSTORE_MessageResultCallback rcb,
204 * Store a state variable.
206 * @param h Handle for the PSYCstore.
207 * @param channel_id The channel we are interested in.
208 * @param name Name of variable.
209 * @param size Size of @a value.
210 * @param value Value of variable.
211 * @param ccb Callback to call with the result of the operation.
212 * @param ccb_cls Closure for the callback.
214 * @return Handle that can be used to cancel the operation.
216 struct GNUNET_PSYCSTORE_OperationHandle *
217 GNUNET_PSYCSTORE_state_set (struct GNUNET_PSYCSTORE_Handle *h,
218 const struct GNUNET_HashCode *channel_id,
222 GNUNET_PSYCSTORE_ContinuationCallback ccb,
227 * Function called with the value of a state variable.
229 * @param cls Closure.
230 * @param name Name of variable.
231 * @param size Size of @a value.
232 * @param value Value of variable.
235 typedef void (*GNUNET_PSYCSTORE_StateResultCallback)(void *cls,
242 * Retrieve the given state variable for a channel.
244 * @param h Handle for the PSYCstore.
245 * @param channel_id The channel we are interested in.
246 * @param name Name of variable to get.
247 * @param rcb Callback to call with the result.
248 * @param rcb_cls Closure for the callback.
250 * @return Handle that can be used to cancel the operation.
252 struct GNUNET_PSYCSTORE_OperationHandle *
253 GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
254 const struct GNUNET_HashCode *channel_id,
256 GNUNET_PSYCSTORE_StateResultCallback rcb,
261 * Retrieve all state variables for a channel.
263 * @param h Handle for the PSYCstore.
264 * @param channel_id The channel we are interested in.
265 * @param rcb Callback to call with the result.
266 * @param rcb_cls Closure for the callback.
268 * @return Handle that can be used to cancel the operation.
270 struct GNUNET_PSYCSTORE_OperationHandle *
271 GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
272 const struct GNUNET_HashCode *channel_id,
273 GNUNET_PSYCSTORE_StateResultCallback rcb,
278 * Cancel an operation.
280 * @param oh Handle for the operation to cancel.
283 GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *oh);
288 #if 0 /* keep Emacsens' auto-indent happy */
295 /* ifndef GNUNET_PSYCSTORE_SERVICE_H */
297 /* end of gnunet_psycstore_service.h */