fixing reconnect issues
[oweals/gnunet.git] / src / datastore / plugin_datastore.h
index 1214ae1be2886c2a3e179732a30dc403f6502eab..e8f43367179c679b99a020e7f44e0fe87a4236b8 100644 (file)
 #ifndef PLUGIN_DATASTORE_H
 #define PLUGIN_DATASTORE_H
 
+#include "gnunet_block_lib.h"
 #include "gnunet_configuration_lib.h"
-#include "gnunet_scheduler_lib.h"
 #include "gnunet_datastore_service.h"
+#include "gnunet_statistics_service.h"
+#include "gnunet_scheduler_lib.h"
+
+
+/**
+ * How many bytes of overhead will we assume per entry
+ * in the SQlite DB?
+ */
+#define GNUNET_DATASTORE_ENTRY_OVERHEAD 256
+
 
 /**
  * The datastore service will pass a pointer to a struct
@@ -44,7 +54,7 @@ struct GNUNET_DATASTORE_PluginEnvironment
   /**
    * Configuration to use.
    */
-  struct GNUNET_CONFIGURATION_Handle *cfg;
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /**
    * Scheduler to use.
@@ -94,7 +104,7 @@ typedef int (*PluginIterator) (void *cls,
                               const GNUNET_HashCode * key,
                               uint32_t size,
                               const void *data,
-                              uint32_t type,
+                              enum GNUNET_BLOCK_Type type,
                               uint32_t priority,
                               uint32_t anonymity,
                               struct GNUNET_TIME_Absolute
@@ -104,6 +114,8 @@ typedef int (*PluginIterator) (void *cls,
 /**
  * Get an estimate of how much space the database is
  * currently using.
+ *
+ * @param cls closure
  * @return number of bytes used on disk
  */
 typedef unsigned long long (*PluginGetSize) (void *cls);
@@ -123,13 +135,15 @@ typedef unsigned long long (*PluginGetSize) (void *cls);
  * @param anonymity anonymity-level for the content
  * @param expiration expiration time for the content
  * @param msg set to an error message (on failure)
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_NO if the content
+ *         was already present (and may have been updated);
+ *         GNUNET_SYSERR on failure
  */
 typedef int (*PluginPut) (void *cls,
                          const GNUNET_HashCode * key,
                          uint32_t size,
                          const void *data,
-                         uint32_t type,
+                         enum GNUNET_BLOCK_Type type,
                          uint32_t priority,
                          uint32_t anonymity,
                          struct GNUNET_TIME_Absolute expiration,
@@ -160,7 +174,7 @@ typedef int (*PluginPut) (void *cls,
 typedef void (*PluginGet) (void *cls,
                           const GNUNET_HashCode * key,
                           const GNUNET_HashCode * vhash,
-                          uint32_t type,
+                          enum GNUNET_BLOCK_Type type,
                           PluginIterator iter, void *iter_cls);
 
 
@@ -175,6 +189,7 @@ typedef void (*PluginGet) (void *cls,
  * Note that it is possible for multiple values to match this put.
  * In that case, all of the respective values are updated.
  *
+ * @param cls closure
  * @param uid unique identifier of the datum
  * @param delta by how much should the priority
  *     change?  If priority + delta < 0 the
@@ -196,6 +211,7 @@ typedef int (*PluginUpdate) (void *cls,
  * Select a subset of the items in the datastore and call
  * the given iterator for each of them.
  *
+ * @param cls closure
  * @param type entries of which type should be considered?
  *        Use 0 for any type.
  * @param iter function to call on each matching value; however,
@@ -207,12 +223,14 @@ typedef int (*PluginUpdate) (void *cls,
  * @param iter_cls closure for iter
  */
 typedef void (*PluginSelector) (void *cls,
-                                uint32_t type,
+                                enum GNUNET_BLOCK_Type type,
                                 PluginIterator iter,
                                 void *iter_cls);
 
 /**
  * Drop database.
+ *
+ * @param cls closure
  */
 typedef void (*PluginDrop) (void *cls);