gnunet_psycstore_service.h 24 KB

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