-adding missing break statements
[oweals/gnunet.git] / src / include / gnunet_psycstore_service.h
index 4f8c6c6c0345997926762eb7146289814c22a80d..29d7ff1ecc9d52f0c946d1399bcabb1e020d2921 100644 (file)
@@ -18,7 +18,7 @@
      Boston, MA 02111-1307, USA.
 */
 
-/** 
+/**
  * @file include/gnunet_psycstore_service.h
  * @brief PSYCstore service; implements persistent storage for the PSYC service
  * @author Gabor X Toth
@@ -40,7 +40,7 @@ extern "C"
 #include "gnunet_multicast_service.h"
 #include "gnunet_psyc_service.h"
 
-/** 
+/**
  * Version number of GNUnet PSYCstore API.
  */
 #define GNUNET_PSYCSTORE_VERSION 0x00000000
@@ -67,13 +67,13 @@ enum GNUNET_PSYCSTORE_MessageFlags
 };
 
 
-/** 
+/**
  * Handle for a PSYCstore
  */
 struct GNUNET_PSYCSTORE_Handle;
 
 
-/** 
+/**
  * Connect to the PSYCstore service.
  *
  * @param cfg Configuration to use.
@@ -84,7 +84,7 @@ struct GNUNET_PSYCSTORE_Handle *
 GNUNET_PSYCSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
-/** 
+/**
  * Disconnect from the PSYCstore service.
  *
  * @param h Handle for the connection.
@@ -93,26 +93,26 @@ void
 GNUNET_PSYCSTORE_disconnect (struct GNUNET_PSYCSTORE_Handle *h);
 
 
-/** 
+/**
  * Handle for an operation on the PSYCSTORE (useful to cancel the operation).
  */
 struct GNUNET_PSYCSTORE_OperationHandle;
 
 
-/** 
+/**
  * Function called with the result of an asynchronous operation.
- * 
+ *
  * @param result #GNUNET_SYSERR on error,
  *        #GNUNET_YES on success or if the peer was a member,
  *        #GNUNET_NO if the peer was not a member
  */
 typedef void
 (*GNUNET_PSYCSTORE_ResultCallback) (void *cls,
-                                    int result,
+                                    int64_t result,
                                     const char *err_msg);
 
 
-/** 
+/**
  * Store join/leave events for a PSYC channel in order to be able to answer
  * membership test queries later.
  *
@@ -133,8 +133,8 @@ typedef void
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
-                                   const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                                   const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
+                                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                                   const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key,
                                    int did_join,
                                    uint64_t announced_at,
                                    uint64_t effective_since,
@@ -143,7 +143,7 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
                                    void *rcb_cls);
 
 
-/** 
+/**
  * Test if a member was admitted to the channel at the given message ID.
  *
  * This is useful when relaying and replaying messages to check if a particular
@@ -165,15 +165,15 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
-                                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                                  const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
+                                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                                  const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key,
                                   uint64_t message_id,
                                   uint64_t group_generation,
                                   GNUNET_PSYCSTORE_ResultCallback rcb,
                                   void *rcb_cls);
 
 
-/** 
+/**
  * Store a message fragment sent to a channel.
  *
  * @param h Handle for the PSYCstore.
@@ -183,26 +183,26 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
  *        state modifiers.
  * @param rcb Callback to call with the result of the operation.
  * @param rcb_cls Closure for the callback.
- * 
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
-                                 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                                 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                  const struct GNUNET_MULTICAST_MessageHeader *message,
                                  uint32_t psycstore_flags,
                                  GNUNET_PSYCSTORE_ResultCallback rcb,
                                  void *rcb_cls);
 
 
-/** 
+/**
  * Function called with one message fragment, as the result of a
  * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call.
  *
  * @param cls Closure.
  * @param message The retrieved message fragment.  A NULL value indicates that
  *        there are no more results to be returned.
- * @param flags Flags stored with the message.
+ * @param psycstore_flags Flags stored with the message.
  *
  * @return #GNUNET_NO to stop calling this callback with further fragments,
  *         #GNUNET_YES to continue.
@@ -210,48 +210,52 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
 typedef int
 (*GNUNET_PSYCSTORE_FragmentCallback) (void *cls,
                                       struct GNUNET_MULTICAST_MessageHeader *message,
-                                      enum GNUNET_PSYCSTORE_MessageFlags flags);
+                                      enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags);
 
 
-/** 
+/**
  * Retrieve a message fragment by fragment ID.
  *
  * @param h Handle for the PSYCstore.
  * @param channel_key The channel we are interested in.
  * @param fragment_id Fragment ID to check.  Use 0 to get the latest message fragment.
- * @param cb Callback to call with the retrieved fragment.
- * @param cb_cls Closure for the callback.
- * 
+ * @param fcb Callback to call with the retrieved fragment.
+ * @param rcb Callback to call with the result of the operation.
+ * @param cls Closure for the callbacks.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h,
-                               const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                               const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                uint64_t fragment_id,
-                               GNUNET_PSYCSTORE_FragmentCallback cb,
-                               void *cb_cls);
+                               GNUNET_PSYCSTORE_FragmentCallback fcb,
+                               GNUNET_PSYCSTORE_ResultCallback rcb,
+                               void *cls);
 
 
-/** 
+/**
  * Retrieve all fragments of a message.
  *
  * @param h Handle for the PSYCstore.
  * @param channel_key The channel we are interested in.
  * @param message_id Message ID to check.  Use 0 to get the latest message.
- * @param cb Callback to call with the retrieved fragments.
- * @param cb_cls Closure for the callback.
- * 
+ * @param fcb Callback to call with the retrieved fragments.
+ * @param rcb Callback to call with the result of the operation.
+ * @param cls Closure for the callbacks.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
-                              const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                              const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                               uint64_t message_id,
-                              GNUNET_PSYCSTORE_FragmentCallback cb,
-                              void *cb_cls);
+                              GNUNET_PSYCSTORE_FragmentCallback fcb,
+                              GNUNET_PSYCSTORE_ResultCallback rcb,
+                              void *cls);
 
 
-/** 
+/**
  * Retrieve a fragment of message specified by its message ID and fragment
  * offset.
  *
@@ -259,92 +263,70 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
  * @param channel_key The channel we are interested in.
  * @param message_id Message ID to check.  Use 0 to get the latest message.
  * @param fragment_offset Offset of the fragment to retrieve.
- * @param cb Callback to call with the retrieved fragments.
- * @param cb_cls Closure for the callback.
- * 
+ * @param fcb Callback to call with the retrieved fragments.
+ * @param rcb Callback to call with the result of the operation.
+ * @param cls Closure for the callbacks.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_message_get_fragment (struct GNUNET_PSYCSTORE_Handle *h,
-                                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                        uint64_t message_id,
                                        uint64_t fragment_offset,
-                                       GNUNET_PSYCSTORE_FragmentCallback cb,
-                                       void *cb_cls);
+                                       GNUNET_PSYCSTORE_FragmentCallback fcb,
+                                       GNUNET_PSYCSTORE_ResultCallback rcb,
+                                       void *cls);
 
 
-/** 
+/**
  * Callback used to return the latest value of counters for the channel master.
  *
- * @see GNUNET_PSYCSTORE_counters_get_master()
- *
- * @param cls Closure.
- * @param fragment_id Latest message fragment ID, used by multicast.
- * @param message_id Latest message ID, used by PSYC.
- * @param group_generation Latest group generation, used by PSYC.
- */
-typedef void
-(*GNUNET_PSYCSTORE_MasterCountersCallback) (void *cls,
-                                            uint64_t fragment_id,
-                                            uint64_t message_id,
-                                            uint64_t group_generation);
-
-
-/** 
- * Callback used to return the latest value of counters for a channel slave.
- *
- * @see GNUNET_PSYCSTORE_counters_get_slave()
+ * @see GNUNET_PSYCSTORE_counters_get()
  *
  * @param cls Closure.
- * @param max_state_msg_id Latest message ID containing state modifiers that was
- *        applied to the state store.  Used for the state sync process.
+ * @param result_code Status code for the operation:
+ *        #GNUNET_OK: success, counter values are returned.
+ *        #GNUNET_NO: no message has been sent to the channel yet.
+ *        #GNUNET_SYSERR: an error occurred.
+ * @param max_fragment_id Latest message fragment ID, used by multicast.
+ * @param max_message_id Latest message ID, used by PSYC.
+ * @param max_group_generation Latest group generation, used by PSYC.
+ * @param max_state_message_id Latest message ID containing state modifiers that
+ *        was applied to the state store.  Used for the state sync process.
  */
 typedef void
-(*GNUNET_PSYCSTORE_SlaveCountersCallback) (void *cls,
-                                           uint64_t max_state_msg_id);
+(*GNUNET_PSYCSTORE_CountersCallback) (void *cls,
+                                      int result_code,
+                                      uint64_t max_fragment_id,
+                                      uint64_t max_message_id,
+                                      uint64_t max_group_generation,
+                                      uint64_t max_state_message_id);
 
 
-/** 
- * Retrieve latest values of counters for a channel master.
+/**
+ * Retrieve latest values of counters for a channel.
  *
- * The current value of counters are needed when a channel master is restarted,
- * so that it can continue incrementing the counters from their last value.
+ * The current value of counters are needed
+ * - when a channel master is restarted, so that it can continue incrementing
+ *   the counters from their last value.
+ * - when a channel slave rejoins and starts the state synchronization process.
  *
  * @param h Handle for the PSYCstore.
  * @param channel_key Public key that identifies the channel.
- * @param cb Callback to call with the result.
- * @param cb_cls Closure for the callback.
- * 
- * @return 
- */
-struct GNUNET_PSYCSTORE_OperationHandle *
-GNUNET_PSYCSTORE_counters_get_master (struct GNUNET_PSYCSTORE_Handle *h,
-                                      struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                                      GNUNET_PSYCSTORE_MasterCountersCallback *cb,
-                                      void *cb_cls);
-
-
-/** 
- * Retrieve latest values of counters for a channel slave.
+ * @param ccb Callback to call with the result.
+ * @param ccb_cls Closure for the @a ccb callback.
  *
- * The current value of counters are needed when a channel slave rejoins
- * and starts the state synchronization process.
- *
- * @param h Handle for the PSYCstore.
- * @param channel_key Public key that identifies the channel.
- * @param cb Callback to call with the result.
- * @param cb_cls Closure for the callback.
- * 
- * @return 
+ * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
-GNUNET_PSYCSTORE_counters_get_slave (struct GNUNET_PSYCSTORE_Handle *h,
-                                     struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                                     GNUNET_PSYCSTORE_SlaveCountersCallback *cb,
-                                     void *cb_cls);
+GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h,
+                               struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                               GNUNET_PSYCSTORE_CountersCallback ccb,
+                               void *ccb_cls);
 
 
-/** 
+/**
  * Apply modifiers of a message to the current channel state.
  *
  * An error is returned if there are missing messages containing state
@@ -353,17 +335,17 @@ GNUNET_PSYCSTORE_counters_get_slave (struct GNUNET_PSYCSTORE_Handle *h,
  * @param h Handle for the PSYCstore.
  * @param channel_key The channel we are interested in.
  * @param message_id ID of the message that contains the @a modifiers.
- * @param state_delta Value of the _state_delta PSYC header variable of the message.
+ * @param state_delta Value of the @e state_delta PSYC header variable of the message.
  * @param modifier_count Number of elements in the @a modifiers array.
  * @param modifiers List of modifiers to apply.
  * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the callback.
- * 
+ * @param rcb_cls Closure for the @a rcb callback.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
-                               const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                               const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                uint64_t message_id,
                                uint64_t state_delta,
                                size_t modifier_count,
@@ -372,7 +354,31 @@ GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
                                void *rcb_cls);
 
 
-/** 
+/**
+ * Store synchronized state.
+ *
+ * @param h Handle for the PSYCstore.
+ * @param channel_key The channel we are interested in.
+ * @param message_id ID of the message that contains the state_hash PSYC header variable.
+ * @param modifier_count Number of elements in the @a modifiers array.
+ * @param modifiers Full state to store.
+ * @param rcb Callback to call with the result of the operation.
+ * @param rcb_cls Closure for the callback.
+ *
+ * @return Handle that can be used to cancel the operation.
+ */
+struct GNUNET_PSYCSTORE_OperationHandle *
+GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h,
+                             const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                             uint64_t message_id,
+                             size_t modifier_count,
+                             const struct GNUNET_ENV_Modifier *modifiers,
+                             GNUNET_PSYCSTORE_ResultCallback rcb,
+                             void *rcb_cls);
+
+
+
+/**
  * Reset the state of a channel.
  *
  * Delete all state variables stored for the given channel.
@@ -381,18 +387,18 @@ GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
  * @param channel_key The channel we are interested in.
  * @param rcb Callback to call with the result of the operation.
  * @param rcb_cls Closure for the callback.
- * 
+ *
  * @return Handle that can be used to cancel the operation.
  */
-struct GNUNET_PSYCSTORE_Handle *
+struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_reset (struct GNUNET_PSYCSTORE_Handle *h,
-                              const struct GNUNET_CRYPTO_EccPublicSignKey
+                              const struct GNUNET_CRYPTO_EddsaPublicKey
                               *channel_key,
                               GNUNET_PSYCSTORE_ResultCallback rcb,
                               void *rcb_cls);
 
 
-/** 
+/**
  * Update signed values of state variables in the state store.
  *
  * @param h Handle for the PSYCstore.
@@ -405,14 +411,14 @@ GNUNET_PSYCSTORE_state_reset (struct GNUNET_PSYCSTORE_Handle *h,
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h,
-                                    const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                                    const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                     uint64_t message_id,
                                     const struct GNUNET_HashCode *hash,
                                     GNUNET_PSYCSTORE_ResultCallback rcb,
                                     void *rcb_cls);
 
 
-/** 
+/**
  * Function called with the value of a state variable.
  *
  * @param cls Closure.
@@ -423,53 +429,55 @@ GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h,
  *
  * @return #GNUNET_NO to stop calling this callback with further variables,
  *         #GNUNET_YES to continue.
- */
+ */;
 typedef int
-(*GNUNET_PSYCSTORE_StateCallback) (void *cls,
-                                   const char *name,
-                                   const void *value,
-                                   size_t value_size);
+(*GNUNET_PSYCSTORE_StateCallback) (void *cls, const char *name,
+                                   const void *value, size_t value_size);
 
 
-/** 
+/**
  * Retrieve the best matching state variable.
  *
  * @param h Handle for the PSYCstore.
  * @param channel_key The channel we are interested in.
  * @param name Name of variable to match, the returned variable might be less specific.
- * @param cb Callback to return matching state variables.
- * @param cb_cls Closure for the callback.
- * 
+ * @param scb Callback to return the matching state variable.
+ * @param rcb Callback to call with the result of the operation.
+ * @param cls Closure for the callbacks.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
-                            const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                            const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                             const char *name,
-                            GNUNET_PSYCSTORE_StateCallback cb,
-                            void *cb_cls);
+                            GNUNET_PSYCSTORE_StateCallback scb,
+                            GNUNET_PSYCSTORE_ResultCallback rcb,
+                            void *cls);
 
 
-/** 
+/**
  * Retrieve all state variables for a channel with the given prefix.
  *
  * @param h Handle for the PSYCstore.
  * @param channel_key The channel we are interested in.
  * @param name_prefix Prefix of state variable names to match.
- * @param cb Callback to return matching state variables.
- * @param cb_cls Closure for the callback.
- * 
+ * @param scb Callback to return matching state variables.
+ * @param rcb Callback to call with the result of the operation.
+ * @param cls Closure for the callbacks.
+ *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
-GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
-                                const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                                const char *name_prefix,
-                                GNUNET_PSYCSTORE_StateCallback cb,
-                                void *cb_cls);
+GNUNET_PSYCSTORE_state_get_prefix (struct GNUNET_PSYCSTORE_Handle *h,
+                                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                                   const char *name_prefix,
+                                   GNUNET_PSYCSTORE_StateCallback scb,
+                                   GNUNET_PSYCSTORE_ResultCallback rcb,
+                                   void *cls);
 
 
-/** 
+/**
  * Cancel an operation.
  *
  * @param op Handle for the operation to cancel.