diff options
Diffstat (limited to 'src/include/gnunet_psycstore_service.h')
-rw-r--r-- | src/include/gnunet_psycstore_service.h | 701 |
1 files changed, 701 insertions, 0 deletions
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h new file mode 100644 index 0000000..92516f4 --- /dev/null +++ b/src/include/gnunet_psycstore_service.h | |||
@@ -0,0 +1,701 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2013 GNUnet e.V. | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Gabor X Toth | ||
23 | * @author Christian Grothoff | ||
24 | * | ||
25 | * @file | ||
26 | * PSYCstore service; implements persistent storage for the PSYC service | ||
27 | * | ||
28 | * @defgroup psycstore PSYC Store service | ||
29 | * Persistent storage for the PSYC service. | ||
30 | * @{ | ||
31 | */ | ||
32 | #ifndef GNUNET_PSYCSTORE_SERVICE_H | ||
33 | #define GNUNET_PSYCSTORE_SERVICE_H | ||
34 | |||
35 | #ifdef __cplusplus | ||
36 | extern "C" | ||
37 | { | ||
38 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
39 | } | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | #include "gnunet_util_lib.h" | ||
44 | #include "gnunet_psyc_util_lib.h" | ||
45 | #include "gnunet_multicast_service.h" | ||
46 | #include "gnunet_psyc_service.h" | ||
47 | |||
48 | /** | ||
49 | * Version number of GNUnet PSYCstore API. | ||
50 | */ | ||
51 | #define GNUNET_PSYCSTORE_VERSION 0x00000000 | ||
52 | |||
53 | /** | ||
54 | * Membership test failed. | ||
55 | */ | ||
56 | #define GNUNET_PSYCSTORE_MEMBERSHIP_TEST_FAILED -2 | ||
57 | |||
58 | /** | ||
59 | * Flags for stored messages. | ||
60 | */ | ||
61 | enum GNUNET_PSYCSTORE_MessageFlags | ||
62 | { | ||
63 | /** | ||
64 | * The message contains state modifiers. | ||
65 | */ | ||
66 | GNUNET_PSYCSTORE_MESSAGE_STATE = 1 << 0, | ||
67 | |||
68 | /** | ||
69 | * The state modifiers have been applied to the state store. | ||
70 | */ | ||
71 | GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED = 1 << 1, | ||
72 | |||
73 | /** | ||
74 | * The message contains a state hash. | ||
75 | */ | ||
76 | GNUNET_PSYCSTORE_MESSAGE_STATE_HASH = 1 << 2 | ||
77 | }; | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Handle for a PSYCstore | ||
82 | */ | ||
83 | struct GNUNET_PSYCSTORE_Handle; | ||
84 | |||
85 | |||
86 | /** | ||
87 | * Connect to the PSYCstore service. | ||
88 | * | ||
89 | * @param cfg Configuration to use. | ||
90 | * | ||
91 | * @return Handle for the connecton. | ||
92 | */ | ||
93 | struct GNUNET_PSYCSTORE_Handle * | ||
94 | GNUNET_PSYCSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Disconnect from the PSYCstore service. | ||
99 | * | ||
100 | * @param h Handle for the connection. | ||
101 | */ | ||
102 | void | ||
103 | GNUNET_PSYCSTORE_disconnect (struct GNUNET_PSYCSTORE_Handle *h); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Handle for an operation on the PSYCSTORE (useful to cancel the operation). | ||
108 | */ | ||
109 | struct GNUNET_PSYCSTORE_OperationHandle; | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Function called with the result of an asynchronous operation. | ||
114 | * | ||
115 | * @param cls | ||
116 | * Closure. | ||
117 | * @param result | ||
118 | * Result of the operation. | ||
119 | * @param err_msg | ||
120 | * Error message, or NULL if there's no error. | ||
121 | * @param err_msg_size | ||
122 | * Size of @a err_msg | ||
123 | */ | ||
124 | typedef void | ||
125 | (*GNUNET_PSYCSTORE_ResultCallback) (void *cls, | ||
126 | int64_t result, | ||
127 | const char *err_msg, | ||
128 | uint16_t err_msg_size); | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Store join/leave events for a PSYC channel in order to be able to answer | ||
133 | * membership test queries later. | ||
134 | * | ||
135 | * @param h | ||
136 | * Handle for the PSYCstore. | ||
137 | * @param channel_key | ||
138 | * The channel where the event happened. | ||
139 | * @param slave_key | ||
140 | * Public key of joining/leaving slave. | ||
141 | * @param did_join | ||
142 | * #GNUNET_YES on join, #GNUNET_NO on part. | ||
143 | * @param announced_at | ||
144 | * ID of the message that announced the membership change. | ||
145 | * @param effective_since | ||
146 | * Message ID this membership change is in effect since. | ||
147 | * For joins it is <= announced_at, for parts it is always 0. | ||
148 | * @param group_generation | ||
149 | * In case of a part, the last group generation the slave has access to. | ||
150 | * It has relevance when a larger message have fragments with different | ||
151 | * group generations. | ||
152 | * @param result_cb | ||
153 | * Callback to call with the result of the storage operation. | ||
154 | * @param cls | ||
155 | * Closure for the callback. | ||
156 | * | ||
157 | * @return Operation handle that can be used to cancel the operation. | ||
158 | */ | ||
159 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
160 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | ||
161 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
162 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
163 | int did_join, | ||
164 | uint64_t announced_at, | ||
165 | uint64_t effective_since, | ||
166 | uint64_t group_generation, | ||
167 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
168 | void *cls); | ||
169 | |||
170 | |||
171 | /** | ||
172 | * Test if a member was admitted to the channel at the given message ID. | ||
173 | * | ||
174 | * This is useful when relaying and replaying messages to check if a particular | ||
175 | * slave has access to the message fragment with a given group generation. It | ||
176 | * is also used when handling join requests to determine whether the slave is | ||
177 | * currently admitted to the channel. | ||
178 | * | ||
179 | * @param h | ||
180 | * Handle for the PSYCstore. | ||
181 | * @param channel_key | ||
182 | * The channel we are interested in. | ||
183 | * @param slave_key | ||
184 | * Public key of slave whose membership to check. | ||
185 | * @param message_id | ||
186 | * Message ID for which to do the membership test. | ||
187 | * @param group_generation | ||
188 | * Group generation of the fragment of the message to test. | ||
189 | * It has relevance if the message consists of multiple fragments with | ||
190 | * different group generations. | ||
191 | * @param result_cb | ||
192 | * Callback to call with the test result. | ||
193 | * @param cls | ||
194 | * Closure for the callback. | ||
195 | * | ||
196 | * @return Operation handle that can be used to cancel the operation. | ||
197 | */ | ||
198 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
199 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | ||
200 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
201 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
202 | uint64_t message_id, | ||
203 | uint64_t group_generation, | ||
204 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
205 | void *cls); | ||
206 | |||
207 | |||
208 | /** | ||
209 | * Store a message fragment sent to a channel. | ||
210 | * | ||
211 | * @param h Handle for the PSYCstore. | ||
212 | * @param channel_key The channel the message belongs to. | ||
213 | * @param msg Message to store. | ||
214 | * @param psycstore_flags Flags indicating whether the PSYC message contains | ||
215 | * state modifiers. | ||
216 | * @param result_cb Callback to call with the result of the operation. | ||
217 | * @param cls Closure for the callback. | ||
218 | * | ||
219 | * @return Handle that can be used to cancel the operation. | ||
220 | */ | ||
221 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
222 | GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, | ||
223 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
224 | const struct GNUNET_MULTICAST_MessageHeader *msg, | ||
225 | enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags, | ||
226 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
227 | void *cls); | ||
228 | |||
229 | |||
230 | /** | ||
231 | * Function called with one message fragment, as the result of a | ||
232 | * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call. | ||
233 | * | ||
234 | * @param cls Closure. | ||
235 | * @param message The retrieved message fragment. A NULL value indicates that | ||
236 | * there are no more results to be returned. | ||
237 | * @param psycstore_flags Flags stored with the message. | ||
238 | * | ||
239 | * @return #GNUNET_NO to stop calling this callback with further fragments, | ||
240 | * #GNUNET_YES to continue. | ||
241 | */ | ||
242 | typedef int | ||
243 | (*GNUNET_PSYCSTORE_FragmentCallback) (void *cls, | ||
244 | struct GNUNET_MULTICAST_MessageHeader *message, | ||
245 | enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags); | ||
246 | |||
247 | |||
248 | /** | ||
249 | * Retrieve message fragments by fragment ID range. | ||
250 | * | ||
251 | * @param h | ||
252 | * Handle for the PSYCstore. | ||
253 | * @param channel_key | ||
254 | * The channel we are interested in. | ||
255 | * @param slave_key | ||
256 | * The slave requesting the fragment. If not NULL, a membership test is | ||
257 | * performed first and the fragment is only returned if the slave has | ||
258 | * access to it. | ||
259 | * @param first_fragment_id | ||
260 | * First fragment ID to retrieve. | ||
261 | * Use 0 to get the latest message fragment. | ||
262 | * @param last_fragment_id | ||
263 | * Last consecutive fragment ID to retrieve. | ||
264 | * Use 0 to get the latest message fragment. | ||
265 | * @param fragment_cb | ||
266 | * Callback to call with the retrieved fragments. | ||
267 | * @param result_cb | ||
268 | * Callback to call with the result of the operation. | ||
269 | * @param cls | ||
270 | * Closure for the callbacks. | ||
271 | * | ||
272 | * @return Handle that can be used to cancel the operation. | ||
273 | */ | ||
274 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
275 | GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h, | ||
276 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
277 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
278 | uint64_t first_message_id, | ||
279 | uint64_t last_message_id, | ||
280 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | ||
281 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
282 | void *cls); | ||
283 | |||
284 | |||
285 | /** | ||
286 | * Retrieve latest message fragments. | ||
287 | * | ||
288 | * @param h | ||
289 | * Handle for the PSYCstore. | ||
290 | * @param channel_key | ||
291 | * The channel we are interested in. | ||
292 | * @param slave_key | ||
293 | * The slave requesting the fragment. If not NULL, a membership test is | ||
294 | * performed first and the fragment is only returned if the slave has | ||
295 | * access to it. | ||
296 | * @param first_fragment_id | ||
297 | * First fragment ID to retrieve. | ||
298 | * Use 0 to get the latest message fragment. | ||
299 | * @param last_fragment_id | ||
300 | * Last consecutive fragment ID to retrieve. | ||
301 | * Use 0 to get the latest message fragment. | ||
302 | * @param fragment_limit | ||
303 | * Maximum number of fragments to retrieve. | ||
304 | * @param fragment_cb | ||
305 | * Callback to call with the retrieved fragments. | ||
306 | * @param result_cb | ||
307 | * Callback to call with the result of the operation. | ||
308 | * @param cls | ||
309 | * Closure for the callbacks. | ||
310 | * | ||
311 | * @return Handle that can be used to cancel the operation. | ||
312 | */ | ||
313 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
314 | GNUNET_PSYCSTORE_fragment_get_latest (struct GNUNET_PSYCSTORE_Handle *h, | ||
315 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
316 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
317 | uint64_t fragment_limit, | ||
318 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | ||
319 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
320 | void *cls); | ||
321 | |||
322 | |||
323 | /** | ||
324 | * Retrieve all fragments of messages in a message ID range. | ||
325 | * | ||
326 | * @param h | ||
327 | * Handle for the PSYCstore. | ||
328 | * @param channel_key | ||
329 | * The channel we are interested in. | ||
330 | * @param slave_key | ||
331 | * The slave requesting the message. | ||
332 | * If not NULL, a membership test is performed first | ||
333 | * and the message is only returned if the slave has access to it. | ||
334 | * @param first_message_id | ||
335 | * First message ID to retrieve. | ||
336 | * @param last_message_id | ||
337 | * Last consecutive message ID to retrieve. | ||
338 | * @param fragment_limit | ||
339 | * Maximum number of fragments to retrieve. | ||
340 | * @param method_prefix | ||
341 | * Retrieve only messages with a matching method prefix. | ||
342 | * @param fragment_cb | ||
343 | * Callback to call with the retrieved fragments. | ||
344 | * @param result_cb | ||
345 | * Callback to call with the result of the operation. | ||
346 | * @param cls | ||
347 | * Closure for the callbacks. | ||
348 | * | ||
349 | * @return Handle that can be used to cancel the operation. | ||
350 | */ | ||
351 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
352 | GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, | ||
353 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
354 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
355 | uint64_t first_message_id, | ||
356 | uint64_t last_message_id, | ||
357 | uint64_t fragment_limit, | ||
358 | const char *method_prefix, | ||
359 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | ||
360 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
361 | void *cls); | ||
362 | |||
363 | |||
364 | /** | ||
365 | * Retrieve all fragments of the latest messages. | ||
366 | * | ||
367 | * @param h | ||
368 | * Handle for the PSYCstore. | ||
369 | * @param channel_key | ||
370 | * The channel we are interested in. | ||
371 | * @param slave_key | ||
372 | * The slave requesting the message. | ||
373 | * If not NULL, a membership test is performed first | ||
374 | * and the message is only returned if the slave has access to it. | ||
375 | * @param message_limit | ||
376 | * Maximum number of messages to retrieve. | ||
377 | * @param method_prefix | ||
378 | * Retrieve only messages with a matching method prefix. | ||
379 | * @param fragment_cb | ||
380 | * Callback to call with the retrieved fragments. | ||
381 | * @param result_cb | ||
382 | * Callback to call with the result of the operation. | ||
383 | * @param cls | ||
384 | * Closure for the callbacks. | ||
385 | * | ||
386 | * @return Handle that can be used to cancel the operation. | ||
387 | */ | ||
388 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
389 | GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h, | ||
390 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
391 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
392 | uint64_t message_limit, | ||
393 | const char *method_prefix, | ||
394 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | ||
395 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
396 | void *cls); | ||
397 | |||
398 | |||
399 | /** | ||
400 | * Retrieve a fragment of message specified by its message ID and fragment | ||
401 | * offset. | ||
402 | * | ||
403 | * @param h | ||
404 | * Handle for the PSYCstore. | ||
405 | * @param channel_key | ||
406 | * The channel we are interested in. | ||
407 | * @param slave_key | ||
408 | * The slave requesting the message fragment. If not NULL, a membership | ||
409 | * test is performed first and the message fragment is only returned | ||
410 | * if the slave has access to it. | ||
411 | * @param message_id | ||
412 | * Message ID to retrieve. Use 0 to get the latest message. | ||
413 | * @param fragment_offset | ||
414 | * Offset of the fragment to retrieve. | ||
415 | * @param fragment_cb | ||
416 | * Callback to call with the retrieved fragments. | ||
417 | * @param result_cb | ||
418 | * Callback to call with the result of the operation. | ||
419 | * @param cls | ||
420 | * Closure for the callbacks. | ||
421 | * | ||
422 | * @return Handle that can be used to cancel the operation. | ||
423 | */ | ||
424 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
425 | GNUNET_PSYCSTORE_message_get_fragment (struct GNUNET_PSYCSTORE_Handle *h, | ||
426 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
427 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
428 | uint64_t message_id, | ||
429 | uint64_t fragment_offset, | ||
430 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | ||
431 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
432 | void *cls); | ||
433 | |||
434 | |||
435 | /** | ||
436 | * Callback used to return the latest value of counters for the channel master. | ||
437 | * | ||
438 | * @see GNUNET_PSYCSTORE_counters_get() | ||
439 | * | ||
440 | * @param cls Closure. | ||
441 | * @param result_code | ||
442 | * Status code for the operation: | ||
443 | * #GNUNET_OK: success, counter values are returned. | ||
444 | * #GNUNET_NO: no message has been sent to the channel yet. | ||
445 | * #GNUNET_SYSERR: an error occurred. | ||
446 | * @param max_fragment_id | ||
447 | * Latest message fragment ID, used by multicast. | ||
448 | * @param max_message_id | ||
449 | * Latest message ID, used by PSYC. | ||
450 | * @param max_group_generation | ||
451 | * Latest group generation, used by PSYC. | ||
452 | * @param max_state_message_id | ||
453 | * Latest message ID containing state modifiers that | ||
454 | * was applied to the state store. Used for the state sync process. | ||
455 | */ | ||
456 | typedef void | ||
457 | (*GNUNET_PSYCSTORE_CountersCallback) (void *cls, | ||
458 | int result_code, | ||
459 | uint64_t max_fragment_id, | ||
460 | uint64_t max_message_id, | ||
461 | uint64_t max_group_generation, | ||
462 | uint64_t max_state_message_id); | ||
463 | |||
464 | |||
465 | /** | ||
466 | * Retrieve latest values of counters for a channel. | ||
467 | * | ||
468 | * The current value of counters are needed | ||
469 | * - when a channel master is restarted, so that it can continue incrementing | ||
470 | * the counters from their last value. | ||
471 | * - when a channel slave rejoins and starts the state synchronization process. | ||
472 | * | ||
473 | * @param h | ||
474 | * Handle for the PSYCstore. | ||
475 | * @param channel_key | ||
476 | * Public key that identifies the channel. | ||
477 | * @param counters_cb | ||
478 | * Callback to call with the result. | ||
479 | * @param cls | ||
480 | * Closure for the @a ccb callback. | ||
481 | * | ||
482 | * @return Handle that can be used to cancel the operation. | ||
483 | */ | ||
484 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
485 | GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h, | ||
486 | struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
487 | GNUNET_PSYCSTORE_CountersCallback counters_cb, | ||
488 | void *cls); | ||
489 | |||
490 | |||
491 | /** | ||
492 | * Apply modifiers of a message to the current channel state. | ||
493 | * | ||
494 | * An error is returned if there are missing messages containing state | ||
495 | * operations before the current one. | ||
496 | * | ||
497 | * @param h | ||
498 | * Handle for the PSYCstore. | ||
499 | * @param channel_key | ||
500 | * The channel we are interested in. | ||
501 | * @param message_id | ||
502 | * ID of the message that contains the @a modifiers. | ||
503 | * @param state_delta | ||
504 | * Value of the @e state_delta PSYC header variable of the message. | ||
505 | * @param result_cb | ||
506 | * Callback to call with the result of the operation. | ||
507 | * @param cls | ||
508 | * Closure for the @a result_cb callback. | ||
509 | * | ||
510 | * @return Handle that can be used to cancel the operation. | ||
511 | */ | ||
512 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
513 | GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h, | ||
514 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
515 | uint64_t message_id, | ||
516 | uint64_t state_delta, | ||
517 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
518 | void *cls); | ||
519 | |||
520 | |||
521 | /** | ||
522 | * Store synchronized state. | ||
523 | * | ||
524 | * @param h | ||
525 | * Handle for the PSYCstore. | ||
526 | * @param channel_key | ||
527 | * The channel we are interested in. | ||
528 | * @param max_state_message_id | ||
529 | * ID of the last stateful message before @a state_hash_message_id. | ||
530 | * @param state_hash_message_id | ||
531 | * ID of the message that contains the state_hash PSYC header variable. | ||
532 | * @param modifier_count | ||
533 | * Number of elements in the @a modifiers array. | ||
534 | * @param modifiers | ||
535 | * Full state to store. | ||
536 | * @param result_cb | ||
537 | * Callback to call with the result of the operation. | ||
538 | * @param cls | ||
539 | * Closure for the callback. | ||
540 | * | ||
541 | * @return Handle that can be used to cancel the operation. | ||
542 | */ | ||
543 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
544 | GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h, | ||
545 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
546 | uint64_t max_state_message_id, | ||
547 | uint64_t state_hash_message_id, | ||
548 | size_t modifier_count, | ||
549 | const struct GNUNET_PSYC_Modifier *modifiers, | ||
550 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
551 | void *cls); | ||
552 | |||
553 | |||
554 | |||
555 | /** | ||
556 | * Reset the state of a channel. | ||
557 | * | ||
558 | * Delete all state variables stored for the given channel. | ||
559 | * | ||
560 | * @param h | ||
561 | * Handle for the PSYCstore. | ||
562 | * @param channel_key | ||
563 | * The channel we are interested in. | ||
564 | * @param result_cb | ||
565 | * Callback to call with the result of the operation. | ||
566 | * @param cls | ||
567 | * Closure for the callback. | ||
568 | * | ||
569 | * @return Handle that can be used to cancel the operation. | ||
570 | */ | ||
571 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
572 | GNUNET_PSYCSTORE_state_reset (struct GNUNET_PSYCSTORE_Handle *h, | ||
573 | const struct GNUNET_CRYPTO_EddsaPublicKey | ||
574 | *channel_key, | ||
575 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
576 | void *cls); | ||
577 | |||
578 | |||
579 | /** | ||
580 | * Update signed values of state variables in the state store. | ||
581 | * | ||
582 | * @param h | ||
583 | * Handle for the PSYCstore. | ||
584 | * @param channel_key | ||
585 | * The channel we are interested in. | ||
586 | * @param message_id | ||
587 | * Message ID that contained the state @a hash. | ||
588 | * @param hash | ||
589 | * Hash of the serialized full state. | ||
590 | * @param result_cb | ||
591 | * Callback to call with the result of the operation. | ||
592 | * @param cls | ||
593 | * Closure for the callback. | ||
594 | * | ||
595 | */ | ||
596 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
597 | GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h, | ||
598 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
599 | uint64_t message_id, | ||
600 | const struct GNUNET_HashCode *hash, | ||
601 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
602 | void *cls); | ||
603 | |||
604 | |||
605 | /** | ||
606 | * Function called with the value of a state variable. | ||
607 | * | ||
608 | * @param cls | ||
609 | * Closure. | ||
610 | * @param name | ||
611 | * Name of the state variable. A NULL value indicates that there are no more | ||
612 | * state variables to be returned. | ||
613 | * @param value | ||
614 | * Value of the state variable. | ||
615 | * @param value_size | ||
616 | * Number of bytes in @a value. | ||
617 | * | ||
618 | * @return #GNUNET_NO to stop calling this callback with further variables, | ||
619 | * #GNUNET_YES to continue. | ||
620 | */; | ||
621 | typedef int | ||
622 | (*GNUNET_PSYCSTORE_StateCallback) (void *cls, const char *name, | ||
623 | const void *value, uint32_t value_size); | ||
624 | |||
625 | |||
626 | /** | ||
627 | * Retrieve the best matching state variable. | ||
628 | * | ||
629 | * @param h | ||
630 | * Handle for the PSYCstore. | ||
631 | * @param channel_key | ||
632 | * The channel we are interested in. | ||
633 | * @param name | ||
634 | * Name of variable to match, the returned variable might be less specific. | ||
635 | * @param state_cb | ||
636 | * Callback to return the matching state variable. | ||
637 | * @param result_cb | ||
638 | * Callback to call with the result of the operation. | ||
639 | * @param cls | ||
640 | * Closure for the callbacks. | ||
641 | * | ||
642 | * @return Handle that can be used to cancel the operation. | ||
643 | */ | ||
644 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
645 | GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h, | ||
646 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
647 | const char *name, | ||
648 | GNUNET_PSYCSTORE_StateCallback state_cb, | ||
649 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
650 | void *cls); | ||
651 | |||
652 | |||
653 | /** | ||
654 | * Retrieve all state variables for a channel with the given prefix. | ||
655 | * | ||
656 | * @param h | ||
657 | * Handle for the PSYCstore. | ||
658 | * @param channel_key | ||
659 | * The channel we are interested in. | ||
660 | * @param name_prefix | ||
661 | * Prefix of state variable names to match. | ||
662 | * @param state_cb | ||
663 | * Callback to return matching state variables. | ||
664 | * @param result_cb | ||
665 | * Callback to call with the result of the operation. | ||
666 | * @param cls | ||
667 | * Closure for the callbacks. | ||
668 | * | ||
669 | * @return Handle that can be used to cancel the operation. | ||
670 | */ | ||
671 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
672 | GNUNET_PSYCSTORE_state_get_prefix (struct GNUNET_PSYCSTORE_Handle *h, | ||
673 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | ||
674 | const char *name_prefix, | ||
675 | GNUNET_PSYCSTORE_StateCallback state_cb, | ||
676 | GNUNET_PSYCSTORE_ResultCallback result_cb, | ||
677 | void *cls); | ||
678 | |||
679 | |||
680 | /** | ||
681 | * Cancel an operation. | ||
682 | * | ||
683 | * @param op Handle for the operation to cancel. | ||
684 | */ | ||
685 | int | ||
686 | GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *op); | ||
687 | |||
688 | |||
689 | |||
690 | |||
691 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
692 | { | ||
693 | #endif | ||
694 | #ifdef __cplusplus | ||
695 | } | ||
696 | #endif | ||
697 | |||
698 | /* ifndef GNUNET_PSYCSTORE_SERVICE_H */ | ||
699 | #endif | ||
700 | |||
701 | /** @} */ /* end of group */ | ||