gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8795 - in gnunet/src: datacache include


From: gnunet
Subject: [GNUnet-SVN] r8795 - in gnunet/src: datacache include
Date: Sun, 26 Jul 2009 15:47:30 -0600

Author: grothoff
Date: 2009-07-26 15:47:30 -0600 (Sun, 26 Jul 2009)
New Revision: 8795

Modified:
   gnunet/src/datacache/perf_datacache_api.c
   gnunet/src/datacache/plugin_datacache_sqlite.c
   gnunet/src/datacache/test_datacache_api.c
   gnunet/src/include/gnunet_datacache_lib.h
   gnunet/src/include/gnunet_dht_service.h
Log:
DHT and datacache API refinements

Modified: gnunet/src/datacache/perf_datacache_api.c
===================================================================
--- gnunet/src/datacache/perf_datacache_api.c   2009-07-26 21:34:10 UTC (rev 
8794)
+++ gnunet/src/datacache/perf_datacache_api.c   2009-07-26 21:47:30 UTC (rev 
8795)
@@ -38,6 +38,7 @@
 
 static int
 checkIt (void *cls,
+        struct GNUNET_TIME_Absolute exp,
         const GNUNET_HashCode * key,
          uint32_t size, 
         const char *data, 

Modified: gnunet/src/datacache/plugin_datacache_sqlite.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_sqlite.c      2009-07-26 21:34:10 UTC 
(rev 8794)
+++ gnunet/src/datacache/plugin_datacache_sqlite.c      2009-07-26 21:47:30 UTC 
(rev 8795)
@@ -170,6 +170,7 @@
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
   struct GNUNET_TIME_Absolute now;
+  struct GNUNET_TIME_Absolute exp;
   unsigned int size;
   const char *dat;
   unsigned int cnt;
@@ -218,7 +219,7 @@
       off = (off + 1) % total;
       GNUNET_snprintf (scratch, 
                       sizeof(scratch),
-                       "SELECT value FROM ds090 WHERE key=? AND type=? AND 
expire >= ? LIMIT 1 OFFSET %u",
+                       "SELECT value,expire FROM ds090 WHERE key=? AND type=? 
AND expire >= ? LIMIT 1 OFFSET %u",
                        off);
       if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK)
         {
@@ -236,8 +237,10 @@
         break;
       size = sqlite3_column_bytes (stmt, 0);
       dat = sqlite3_column_blob (stmt, 0);
+      exp.value = sqlite3_column_int64 (stmt, 1);
       cnt++;
       if (GNUNET_OK != iter (iter_cls,
+                            exp,
                             key, 
                             size,
                             dat,

Modified: gnunet/src/datacache/test_datacache_api.c
===================================================================
--- gnunet/src/datacache/test_datacache_api.c   2009-07-26 21:34:10 UTC (rev 
8794)
+++ gnunet/src/datacache/test_datacache_api.c   2009-07-26 21:47:30 UTC (rev 
8795)
@@ -35,6 +35,7 @@
 
 static int
 checkIt (void *cls,
+        struct GNUNET_TIME_Absolute exp,
         const GNUNET_HashCode * key,
          uint32_t size, 
         const char *data, 

Modified: gnunet/src/include/gnunet_datacache_lib.h
===================================================================
--- gnunet/src/include/gnunet_datacache_lib.h   2009-07-26 21:34:10 UTC (rev 
8794)
+++ gnunet/src/include/gnunet_datacache_lib.h   2009-07-26 21:47:30 UTC (rev 
8795)
@@ -74,6 +74,7 @@
  * An iterator over a set of items stored in the datacache.
  *
  * @param cls closure
+ * @param exp when will the content expire?
  * @param key key for the content
  * @param size number of bytes in data
  * @param data content stored
@@ -81,6 +82,7 @@
  * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort
  */
 typedef int (*GNUNET_DATACACHE_Iterator) (void *cls,
+                                         struct GNUNET_TIME_Absolute exp,
                                          const GNUNET_HashCode * key,
                                          uint32_t size,
                                          const char *data,

Modified: gnunet/src/include/gnunet_dht_service.h
===================================================================
--- gnunet/src/include/gnunet_dht_service.h     2009-07-26 21:34:10 UTC (rev 
8794)
+++ gnunet/src/include/gnunet_dht_service.h     2009-07-26 21:47:30 UTC (rev 
8795)
@@ -37,11 +37,60 @@
 #endif
 #endif
 
-// FIXME: document
+
+/**
+ * Connection to the DHT service.
+ */
+struct GNUNET_DHT_Handle;
+
+
+/**
+ * Initialize the connection with the DHT service.
+ * 
+ * @param cfg configuration to use
+ * @param sched scheduler to use
+ * @return NULL on error
+ */
+struct GNUNET_DHT_Handle *
+GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                   struct GNUNET_SCHEDULER_Handle *sched);
+
+
+/**
+ * Shutdown connection with the DHT service.
+ *
+ * @param h connection to shut down
+ */
+void
+GNUNET_DHT_connect (struct GNUNET_DHT_Handle *h);
+
+
+/**
+ * Handle to control a GET operation.
+ */
 struct GNUNET_DHT_GetHandle;
 
 
 /**
+ * Iterator called on each result obtained for a GET
+ * operation.
+ *
+ * @param cls closure
+ * @param exp when will this value expire
+ * @param key key of the result
+ * @param type type of the result
+ * @param size number of bytes in data
+ * @param data pointer to the result data
+ */
+typedef void (*GNUNET_DHT_Iterator)(void *cls,
+                                   struct GNUNET_TIME_Absolute exp,
+                                   const GNUNET_HashCode * key,
+                                   uint32_t type,
+                                   uint32_t size,
+                                   const void *data);
+                     
+
+/**
  * Perform an asynchronous GET operation on the DHT identified.
  *
  * @param type expected type of the response object
@@ -60,23 +109,38 @@
 
 /**
  * Stop async DHT-get.  Frees associated resources.
+ *
+ * @param record GET operation to stop.
  */
-int GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *record);
+void
+GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *record);
 
 
-// FIXME: add continuation? expiration?
 /**
  * Perform a PUT operation on the DHT identified by 'table' storing
  * a binding of 'key' to 'value'.  The peer does not have to be part
  * of the table (if so, we will attempt to locate a peer that is!)
  *
+ * @param h handle to DHT service
  * @param key the key to store under
+ * @param type type of the value
+ * @param size number of bytes in data; must be less than 64k
+ * @param data the data to store
+ * @param exp desired expiration time for the value
+ * @param cont continuation to call when done; 
+ *             reason will be TIMEOUT on error,
+ *             reason will be PREREQ_DONE on success
+ * @param cont_cls closure for cont
+ * 
  */
 int GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, 
                    const GNUNET_HashCode * key,
-                   uint32_t type, 
+                   uint32_t type,                  
                    uint32_t size, 
-                   const char *data);
+                   const char *data,
+                   struct GNUNET_TIME_Relative exp,
+                   GNUNET_SCHEDULER_Task cont,
+                   void *cont_cls);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]