client_manager: add API for async operations
[oweals/gnunet.git] / src / include / gnunet_psycstore_plugin.h
index 8f8668043970c4bb3b5b95fe721b8a637aa2ea3d..8d491469b2b23ecc808ffd697dd1a549f308b6ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -59,8 +59,8 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*membership_store) (void *cls,
-                       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_EcdsaPublicKey *slave_key,
                        int did_join,
                        uint64_t announced_at,
                        uint64_t effective_since,
@@ -76,8 +76,8 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*membership_test) (void *cls,
-                      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_EcdsaPublicKey *slave_key,
                       uint64_t message_id);
 
   /**
@@ -89,7 +89,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*fragment_store) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                      const struct GNUNET_MULTICAST_MessageHeader *message,
                      uint32_t psycstore_flags);
 
@@ -107,12 +107,12 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_add_flags) (void *cls,
-                        const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                        const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                         uint64_t message_id,
                         uint64_t psycstore_flags);
 
   /**
-   * Retrieve a message fragment by fragment ID.
+   * Retrieve a message fragment range by fragment ID.
    *
    * @see GNUNET_PSYCSTORE_fragment_get()
    *
@@ -120,13 +120,30 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*fragment_get) (void *cls,
-                   const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                   uint64_t fragment_id,
+                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                   uint64_t first_fragment_id,
+                   uint64_t last_fragment_id,
+                   uint64_t *returned_fragments,
                    GNUNET_PSYCSTORE_FragmentCallback cb,
                    void *cb_cls);
 
   /**
-   * Retrieve all fragments of a message.
+   * Retrieve latest message fragments.
+   *
+   * @see GNUNET_PSYCSTORE_fragment_get()
+   *
+   * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+   */
+  int
+  (*fragment_get_latest) (void *cls,
+                          const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                          uint64_t fragment_limit,
+                          uint64_t *returned_fragments,
+                          GNUNET_PSYCSTORE_FragmentCallback cb,
+                          void *cb_cls);
+
+  /**
+   * Retrieve all fragments of a message ID range.
    *
    * @see GNUNET_PSYCSTORE_message_get()
    *
@@ -134,12 +151,28 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_get) (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                  uint64_t message_id,
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                  uint64_t first_fragment_id,
+                  uint64_t last_fragment_id,
                   uint64_t *returned_fragments,
                   GNUNET_PSYCSTORE_FragmentCallback cb,
                   void *cb_cls);
 
+  /**
+   * Retrieve all fragments of the latest messages.
+   *
+   * @see GNUNET_PSYCSTORE_message_get()
+   *
+   * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+   */
+  int
+  (*message_get_latest) (void *cls,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                         uint64_t fragment_limit,
+                         uint64_t *returned_fragments,
+                         GNUNET_PSYCSTORE_FragmentCallback cb,
+                         void *cb_cls);
+
   /**
    * Retrieve a fragment of message specified by its message ID and fragment
    * offset.
@@ -150,7 +183,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_get_fragment) (void *cls,
-                           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,
@@ -165,7 +198,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*counters_message_get) (void *cls,
-                           const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                           const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                            uint64_t *max_fragment_id,
                            uint64_t *max_message_id,
                            uint64_t *max_group_generation);
@@ -179,7 +212,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*counters_state_get) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                          uint64_t *max_state_message_id);
 
 
@@ -192,7 +225,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_modify_begin) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                          uint64_t message_id, uint64_t state_delta);
 
   /**
@@ -208,7 +241,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_modify_set) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        const char *name, const void *value, size_t value_size);
 
 
@@ -221,7 +254,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_modify_end) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        uint64_t message_id);
 
 
@@ -234,7 +267,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_sync_begin) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
   /**
    * Set the value of a state variable while synchronizing state.
@@ -249,7 +282,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_sync_set) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                      const char *name, const void *value, size_t value_size);
 
 
@@ -262,7 +295,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_sync_end) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                      uint64_t message_id);
 
 
@@ -277,7 +310,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_reset) (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
   /**
    * Update signed state values from the current ones.
@@ -286,7 +319,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_update_signed) (void *cls,
-                          const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                          const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
 
   /**
@@ -296,7 +329,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_get) (void *cls,
-                const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                 const char *name,
                 GNUNET_PSYCSTORE_StateCallback cb,
                 void *cb_cls);
@@ -310,7 +343,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_get_prefix) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        const char *name,
                        GNUNET_PSYCSTORE_StateCallback cb,
                        void *cb_cls);
@@ -323,7 +356,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_get_signed) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        GNUNET_PSYCSTORE_StateCallback cb,
                        void *cb_cls);