(no commit message)
[oweals/gnunet.git] / src / datastore / plugin_datastore.h
index 775a6641a6ff9bf3c2e4ca6aabe847aeeb08a772..fa08501cc87cb5edab23398589384e1b079b9b88 100644 (file)
  * @file datastore/plugin_datastore.h
  * @brief API for the database backend plugins.
  * @author Christian Grothoff
- *
- * TODO:
- * - consider defining enumeration or at least typedef
- *   for the type of "type" (instead of using uint32_t)
  */
 #ifndef PLUGIN_DATASTORE_H
 #define PLUGIN_DATASTORE_H
 
+#include "gnunet_block_lib.h"
 #include "gnunet_configuration_lib.h"
 #include "gnunet_datastore_service.h"
 #include "gnunet_statistics_service.h"
 
 /**
  * How many bytes of overhead will we assume per entry
- * in the SQlite DB?
+ * in any DB (for reservations)?
  */
 #define GNUNET_DATASTORE_ENTRY_OVERHEAD 256
 
 
+/**
+ * Function invoked to notify service of disk utilization
+ * changes.
+ *
+ * @param cls closure
+ * @param delta change in disk utilization, 
+ *        0 for "reset to empty"
+ */
+typedef void (*DiskUtilizationChange)(void *cls,
+                                     int delta);
+
+
 /**
  * The datastore service will pass a pointer to a struct
  * of this type as the first and only argument to the
@@ -60,6 +69,16 @@ struct GNUNET_DATASTORE_PluginEnvironment
    */
   struct GNUNET_SCHEDULER_Handle *sched;
 
+  /**
+   * Function to call on disk utilization change.
+   */
+  DiskUtilizationChange duc;
+
+  /**
+   * Closure.
+   */
+  void *cls;
+
 };
 
 
@@ -103,7 +122,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
@@ -142,7 +161,7 @@ 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,
@@ -173,7 +192,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);
 
 
@@ -222,7 +241,7 @@ 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);