aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/datacache/perf_datacache_api.c1
-rw-r--r--src/datacache/plugin_datacache_sqlite.c5
-rw-r--r--src/datacache/test_datacache_api.c1
-rw-r--r--src/include/gnunet_datacache_lib.h2
-rw-r--r--src/include/gnunet_dht_service.h74
5 files changed, 77 insertions, 6 deletions
diff --git a/src/datacache/perf_datacache_api.c b/src/datacache/perf_datacache_api.c
index aa008a3322..aa11fe122e 100644
--- a/src/datacache/perf_datacache_api.c
+++ b/src/datacache/perf_datacache_api.c
@@ -38,6 +38,7 @@ static unsigned int found;
static int
checkIt (void *cls,
+ struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 51bbf60d73..5493dbb905 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -170,6 +170,7 @@ sqlite_plugin_get (void *cls,
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 @@ sqlite_plugin_get (void *cls,
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 @@ sqlite_plugin_get (void *cls,
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,
diff --git a/src/datacache/test_datacache_api.c b/src/datacache/test_datacache_api.c
index 5207fa2a5d..8a5a356d26 100644
--- a/src/datacache/test_datacache_api.c
+++ b/src/datacache/test_datacache_api.c
@@ -35,6 +35,7 @@ static int ok;
static int
checkIt (void *cls,
+ struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 8eb724bfa2..3bd76df328 100644
--- a/src/include/gnunet_datacache_lib.h
+++ b/src/include/gnunet_datacache_lib.h
@@ -74,6 +74,7 @@ void GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
* 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 @@ void GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
* @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,
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 8dcbc19c53..0dab0bcbce 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -37,11 +37,60 @@ extern "C"
#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 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h,
/**
* 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 */