remove protocol violation
[oweals/gnunet.git] / src / psycstore / plugin_psycstore_sqlite.c
index 592eaf384325950811d5af103fffe0bf70598dda..6ca0236d59040c0ec5f792b872cf36c66610bc15 100644 (file)
@@ -435,7 +435,7 @@ database_setup (struct Plugin *plugin)
                &plugin->select_membership);
 
   sql_prepare (plugin->dbh,
-               "INSERT INTO messages\n"
+               "INSERT OR IGNORE INTO messages\n"
                " (channel_id, hop_counter, signature, purpose,\n"
                "  fragment_id, fragment_offset, message_id,\n"
                "  group_generation, multicast_flags, psycstore_flags, data)\n"
@@ -610,18 +610,18 @@ database_shutdown (struct Plugin *plugin)
   GNUNET_free_non_null (plugin->fn);
 }
 
-/** 
+/**
  * Execute a prepared statement with a @a channel_key argument.
  *
  * @param plugin Plugin handle.
  * @param stmt Statement to execute.
  * @param channel_key Public key of the channel.
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 exec_channel (struct Plugin *plugin, sqlite3_stmt *stmt,
-              const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key)
+              const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
 {
   if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, channel_key,
                                       sizeof (*channel_key), SQLITE_STATIC))
@@ -721,7 +721,7 @@ transaction_rollback (struct Plugin *plugin)
 
 static int
 channel_key_store (struct Plugin *plugin,
-                   const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key)
+                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
 {
   sqlite3_stmt *stmt = plugin->insert_channel_key;
 
@@ -750,7 +750,7 @@ channel_key_store (struct Plugin *plugin,
 
 static int
 slave_key_store (struct Plugin *plugin,
-                 const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key)
+                 const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key)
 {
   sqlite3_stmt *stmt = plugin->insert_slave_key;
 
@@ -778,7 +778,7 @@ slave_key_store (struct Plugin *plugin,
 }
 
 
-/** 
+/**
  * Store join/leave events for a PSYC channel in order to be able to answer
  * membership test queries later.
  *
@@ -788,8 +788,8 @@ slave_key_store (struct Plugin *plugin,
  */
 static 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_EddsaPublicKey *slave_key,
                   int did_join,
                   uint64_t announced_at,
                   uint64_t effective_since,
@@ -840,18 +840,18 @@ membership_store (void *cls,
   return GNUNET_OK;
 }
 
-/** 
+/**
  * Test if a member was admitted to the channel at the given message ID.
  *
  * @see GNUNET_PSYCSTORE_membership_test()
- * 
+ *
  * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
  *         #GNUNET_SYSERR if there was en error.
  */
 static 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_EddsaPublicKey *slave_key,
                  uint64_t message_id)
 {
   struct Plugin *plugin = cls;
@@ -888,16 +888,16 @@ membership_test (void *cls,
   return ret;
 }
 
-/** 
+/**
  * Store a message fragment sent to a channel.
  *
  * @see GNUNET_PSYCSTORE_fragment_store()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 fragment_store (void *cls,
-                const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                 const struct GNUNET_MULTICAST_MessageHeader *msg,
                 uint32_t psycstore_flags)
 {
@@ -961,16 +961,16 @@ fragment_store (void *cls,
   return GNUNET_OK;
 }
 
-/** 
+/**
  * Set additional flags for a given message.
  *
  * They are OR'd with any existing flags set.
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
 {
@@ -1036,16 +1036,16 @@ fragment_row (sqlite3_stmt *stmt, GNUNET_PSYCSTORE_FragmentCallback cb,
   return cb (cb_cls, (void *) msg, sqlite3_column_int64 (stmt, 8));
 }
 
-/** 
+/**
  * Retrieve a message fragment by fragment ID.
  *
  * @see GNUNET_PSYCSTORE_fragment_get()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 fragment_get (void *cls,
-              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)
@@ -1087,16 +1087,16 @@ fragment_get (void *cls,
   return ret;
 }
 
-/** 
+/**
  * Retrieve all fragments of a message.
  *
  * @see GNUNET_PSYCSTORE_message_get()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 message_get (void *cls,
-             const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+             const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
              uint64_t message_id,
              uint64_t *returned_fragments,
              GNUNET_PSYCSTORE_FragmentCallback cb,
@@ -1150,17 +1150,17 @@ message_get (void *cls,
   return ret;
 }
 
-/** 
+/**
  * Retrieve a fragment of message specified by its message ID and fragment
  * offset.
  *
  * @see GNUNET_PSYCSTORE_message_get_fragment()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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,
@@ -1204,16 +1204,16 @@ message_get_fragment (void *cls,
   return ret;
 }
 
-/** 
+/**
  * Retrieve the max. values of message counters for a channel.
  *
  * @see GNUNET_PSYCSTORE_counters_get()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
@@ -1257,16 +1257,16 @@ counters_message_get (void *cls,
   return ret;
 }
 
-/** 
+/**
  * Retrieve the max. values of state counters for a channel.
  *
  * @see GNUNET_PSYCSTORE_counters_get()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
 {
   struct Plugin *plugin = cls;
@@ -1307,14 +1307,14 @@ counters_state_get (void *cls,
 }
 
 
-/** 
+/**
  * Set a state variable to the given value.
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 state_set (struct Plugin *plugin, sqlite3_stmt *stmt,
-           const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+           const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
            const char *name, const void *value, size_t value_size)
 {
   int ret = GNUNET_SYSERR;
@@ -1354,7 +1354,7 @@ state_set (struct Plugin *plugin, sqlite3_stmt *stmt,
 
 static int
 update_message_id (struct Plugin *plugin, sqlite3_stmt *stmt,
-                   const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                    uint64_t message_id)
 {
   if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, message_id)
@@ -1384,7 +1384,7 @@ update_message_id (struct Plugin *plugin, sqlite3_stmt *stmt,
  */
 static 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)
 {
   struct Plugin *plugin = cls;
@@ -1440,16 +1440,16 @@ state_modify_begin (void *cls,
 }
 
 
-/** 
+/**
  * Set the current value of state variable.
  *
  * @see GNUNET_PSYCSTORE_state_modify()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
 {
   struct Plugin *plugin = cls;
@@ -1466,7 +1466,7 @@ state_modify_set (void *cls,
  */
 static int
 state_modify_end (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                   uint64_t message_id)
 {
   struct Plugin *plugin = cls;
@@ -1487,23 +1487,23 @@ state_modify_end (void *cls,
  */
 static int
 state_sync_begin (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key)
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
 {
   struct Plugin *plugin = cls;
   return exec_channel (plugin, plugin->delete_state_sync, channel_key);
 }
 
 
-/** 
+/**
  * Set the current value of state variable.
  *
  * @see GNUNET_PSYCSTORE_state_modify()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
 {
   struct Plugin *plugin = cls;
@@ -1517,7 +1517,7 @@ state_sync_set (void *cls,
  */
 static int
 state_sync_end (void *cls,
-                const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                 uint64_t message_id)
 {
   struct Plugin *plugin = cls;
@@ -1539,46 +1539,46 @@ state_sync_end (void *cls,
 }
 
 
-/** 
+/**
  * Reset the state of a channel.
  *
  * @see GNUNET_PSYCSTORE_state_reset()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
-state_reset (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key)
+state_reset (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
 {
   struct Plugin *plugin = cls;
   return exec_channel (plugin, plugin->delete_state, channel_key);
 }
 
 
-/** 
+/**
  * Update signed values of state variables in the state store.
  *
  * @see GNUNET_PSYCSTORE_state_hash_update()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
 state_update_signed (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key)
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
 {
   struct Plugin *plugin = cls;
   return exec_channel (plugin, plugin->update_state_signed, channel_key);
 }
 
 
-/** 
+/**
  * Retrieve a state variable by name.
  *
  * @see GNUNET_PSYCSTORE_state_get()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
-state_get (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+state_get (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
            const char *name, GNUNET_PSYCSTORE_StateCallback cb, void *cb_cls)
 {
   struct Plugin *plugin = cls;
@@ -1621,15 +1621,15 @@ state_get (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
 }
 
 
-/** 
+/**
  * Retrieve all state variables for a channel with the given prefix.
  *
  * @see GNUNET_PSYCSTORE_state_get_prefix()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static int
-state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                   const char *name, GNUNET_PSYCSTORE_StateCallback cb,
                   void *cb_cls)
 {
@@ -1688,16 +1688,16 @@ state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *channe
 }
 
 
-/** 
+/**
  * Retrieve all signed state variables for a channel.
  *
  * @see GNUNET_PSYCSTORE_state_get_signed()
- * 
+ *
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
 static 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)
 {
   struct Plugin *plugin = cls;
@@ -1748,7 +1748,7 @@ state_get_signed (void *cls,
 }
 
 
-/** 
+/**
  * Entry point for the plugin.
  *
  * @param cls The struct GNUNET_CONFIGURATION_Handle.