[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r155 - in GNUnet: . src/applications/dht/module src/include
From: |
grothoff |
Subject: |
[GNUnet-SVN] r155 - in GNUnet: . src/applications/dht/module src/include |
Date: |
Wed, 2 Feb 2005 02:09:24 -0800 (PST) |
Author: grothoff
Date: 2005-02-02 02:09:23 -0800 (Wed, 02 Feb 2005)
New Revision: 155
Modified:
GNUnet/src/applications/dht/module/datastore_memory.c
GNUnet/src/applications/dht/module/datastore_memory_test.c
GNUnet/src/include/gnunet_blockstore.h
GNUnet/todo
Log:
making datastore memory test work again
Modified: GNUnet/src/applications/dht/module/datastore_memory.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_memory.c 2005-02-02
09:38:35 UTC (rev 154)
+++ GNUnet/src/applications/dht/module/datastore_memory.c 2005-02-02
10:09:23 UTC (rev 155)
@@ -154,6 +154,7 @@
pos->key = *key;
pos->count = 1;
pos->values = MALLOC(sizeof(DataContainer*));
+ pos->values[0] = MALLOC(size);
memcpy(pos->values[0],
value,
size);
@@ -281,7 +282,7 @@
* Create a DHT Datastore (in memory)
* @param max_memory do not use more than max_memory memory.
*/
-Blockstore * create_datastore_memory(size_t max_memory) {
+Blockstore * create_blockstore_memory(size_t max_memory) {
Blockstore * res;
MemoryDatastore * md;
@@ -304,7 +305,7 @@
* @param ds the Datastore to destroy; must have been
* created by create_datastore_memory.
*/
-void destroy_datastore_memory(Blockstore * ds) {
+void destroy_blockstore_memory(Blockstore * ds) {
MemoryDatastore * md;
HT_Entry * pos;
HT_Entry * next;
Modified: GNUnet/src/applications/dht/module/datastore_memory_test.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_memory_test.c 2005-02-02
09:38:35 UTC (rev 154)
+++ GNUnet/src/applications/dht/module/datastore_memory_test.c 2005-02-02
10:09:23 UTC (rev 155)
@@ -18,7 +18,7 @@
*/
/**
- * @file applications/dht/module/datastore_memory_test.h
+ * @file applications/dht/module/datastore_memory_test.c
* @brief testcase for the Datastore API (memory).
* @author Christian Grothoff
*
@@ -32,147 +32,147 @@
#define DUMP(v) fprintf(stderr, "At %d: \n", __LINE__);
-static int store(DHT_Datastore * s,
+static int store(Blockstore * s,
char * key,
- char * val,
- int flags) {
+ char * val) {
HashCode160 hc;
- DHT_DataContainer cont;
+ DataContainer * cont;
- cont.dataLength = strlen(val);
- cont.data = val;
+ cont = MALLOC(sizeof(DataContainer) + strlen(val));
+ cont->size = htonl(strlen(val) + sizeof(DataContainer));
+ memcpy(&cont[1],
+ val,
+ strlen(val));
hash(key,
strlen(key),
&hc);
- if (OK != s->store(s->closure,
- &hc,
- &cont,
- flags))
- { DUMP(s); return 1; }
+ if (OK != s->put(s->closure,
+ &hc,
+ 0,
+ cont,
+ 0)) {
+ DUMP(s);
+ FREE(cont);
+ return 1;
+ }
+ FREE(cont);
return 0;
}
-static int rem(DHT_Datastore * s,
+static int rem(Blockstore * s,
char * key,
- char * val,
- int flags) {
+ char * val) {
HashCode160 hc;
- DHT_DataContainer cont;
+ DataContainer * cont;
- if (val == NULL)
- cont.dataLength = 0;
- else
- cont.dataLength = strlen(val);
- cont.data = val;
+ if (val == NULL) {
+ cont = NULL;
+ } else {
+ cont = MALLOC(sizeof(DataContainer) + strlen(val));
+ cont->size = htonl(strlen(val) + sizeof(DataContainer));
+ memcpy(&cont[1],
+ val,
+ strlen(val));
+ }
hash(key,
strlen(key),
&hc);
- if (OK != s->remove(s->closure,
- &hc,
- &cont,
- flags))
- { DUMP(s); return 1; }
+ if (OK != s->del(s->closure,
+ &hc,
+ 0,
+ cont)) {
+ FREE(cont);
+ DUMP(s);
+ return 1;
+ }
+ FREE(cont);
return 0;
}
-static int load(DHT_Datastore * s,
+static int resCB(const HashCode160 * key,
+ const DataContainer * val,
+ void * cls) {
+ DataContainer ** trg = cls;
+ *trg = MALLOC(ntohl(val->size));
+ memcpy(*trg,
+ val,
+ ntohl(val->size));
+ return OK;
+}
+
+static int load(Blockstore * s,
char * key,
- char * val,
- int flags) {
+ char * val) {
HashCode160 hc;
- DHT_DataContainer cont;
+ DataContainer * cont;
- cont.dataLength = 0;
- cont.data = NULL;
+ cont = NULL;
hash(key,
strlen(key),
&hc);
- if (OK != s->lookup(s->closure,
- &hc,
- 1,
- &cont,
- flags))
- { DUMP(s); return 1; }
+ if (OK != s->get(s->closure,
+ 0,
+ 0,
+ 1,
+ &hc,
+ &resCB,
+ &cont)) {
+ if (val == NULL)
+ return 0;
+ DUMP(s);
+ return 1;
+ } else if (val == NULL) {
+ FREE(cont);
+ DUMP(s);
+ return 1;
+ }
+ if ( (val == NULL) &&
+ (cont == NULL) )
+ return 0;
+ if ( (val == NULL) &&
+ (cont != NULL) ) {
+ DUMP(s);
+ FREE(cont);
+ return 1;
+ }
+ if (cont == NULL) {
+ DUMP(s);
+ return 1;
+ }
if (0 != strncmp(val,
- (char*)cont.data,
- strlen(val)))
+ (char*) &cont[1],
+ strlen(val))) {
+ DUMP(s);
return 1;
- FREENONNULL(cont.data);
+ }
+ FREE(cont);
return 0;
}
-static int test(DHT_Datastore * s) {
- DHT_DataContainer containers[4];
- char data[24];
- int i;
- HashCode160 key1;
- HashCode160 key2;
+static int test(Blockstore * s) {
+ GNUNET_ASSERT(0 == store(s, "a", "Hello"));
+ GNUNET_ASSERT(0 == store(s, "b", "World"));
+ GNUNET_ASSERT(0 == load(s, "a", "Hello"));
+ GNUNET_ASSERT(0 == load(s, "b", "World"));
+ GNUNET_ASSERT(0 == rem(s, "a", "Hello"));
+ GNUNET_ASSERT(0 == rem(s, "b", "World"));
+ GNUNET_ASSERT(0 == load(s, "a", NULL));
+ GNUNET_ASSERT(0 == load(s, "b", NULL));
- for (i=0;i<24;i++)
- data[i] = i;
- key1.a = 4;
- key2.a = 5;
- containers[0].dataLength = 24;
- containers[0].data = &data[0];
- if (OK != s->store(s->closure,
- &key1,
- &containers[0],
- DHT_FLAGS__APPEND))
- { DUMP(s); return 1; }
- containers[1].dataLength = 0;
- containers[1].data = NULL;
- if (0 != s->lookup(s->closure,
- &key2, 3,
- &containers[1],
- DHT_FLAGS__APPEND))
- { DUMP(s); return 1; }
- if (1 != s->lookup(s->closure,
- &key1, 3,
- &containers[1],
- DHT_FLAGS__APPEND))
- { DUMP(s); return 1; }
- if ( (containers[1].dataLength != containers[0].dataLength) ||
- (0 != memcmp(containers[1].data,
- containers[0].data,
- containers[1].dataLength)) )
- { DUMP(s); return 1; }
- FREE(containers[1].data);
- containers[1].dataLength = 0;
- containers[1].data = NULL;
- if (OK != s->remove(s->closure,
- &key1,
- NULL,
- DHT_FLAGS__APPEND))
- { DUMP(s); return 1; }
- if (0 != s->lookup(s->closure,
- &key1, 3,
- &containers[1],
- DHT_FLAGS__APPEND))
- { DUMP(s); return 1; }
-
-
- GNUNET_ASSERT(0 == store(s, "a", "Hello", 0));
- GNUNET_ASSERT(0 == store(s, "b", "World", 0));
- GNUNET_ASSERT(0 == load(s, "a", "Hello", 0));
- GNUNET_ASSERT(0 == load(s, "b", "World", 0));
- GNUNET_ASSERT(0 == rem(s, "a", "Hello", 0));
- GNUNET_ASSERT(0 == rem(s, "b", "World", 0));
-
-
return 0;
}
int main(int args,
char * argv[]) {
- DHT_Datastore * s;
+ Blockstore * s;
int i;
- s = create_datastore_memory(65536);
+ s = create_blockstore_memory(65536);
for (i=0;i<65536;i++)
if (0 != test(s))
{ DUMP(s); return 1; }
- destroy_datastore_memory(s);
+ destroy_blockstore_memory(s);
return 0;
}
Modified: GNUnet/src/include/gnunet_blockstore.h
===================================================================
--- GNUnet/src/include/gnunet_blockstore.h 2005-02-02 09:38:35 UTC (rev
154)
+++ GNUnet/src/include/gnunet_blockstore.h 2005-02-02 10:09:23 UTC (rev
155)
@@ -26,6 +26,8 @@
#ifndef GNUNET_BLOCKSTORE_H
#define GNUNET_BLOCKSTORE_H
+#include "gnunet_util.h"
+
/**
* Data stored in the blockstore.
*/
@@ -60,7 +62,7 @@
* routing, the other parts are just passed along and untouched by the
* routing code. The type is typically used to tell what they refer
* to. The assumption is that they (including the type) can be
- * reproduced from the DataContainer and thus the Iterator and put
+ * reproduced from the DataContainer and thus the Iterator
* methods do not communicate those values.
*
* The put method is (ab)used to check an item that is merely routed
@@ -77,7 +79,7 @@
* Lookup an item in the datastore.
*
* @param type kind of item to look up
- * @param prio how important is this for the routing code?
+ * @param prio how important is this lookup
* @param keyCount number of keys given
* @param keys to look up
* @param resultCallback function to call for each result that was found
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-02 09:38:35 UTC (rev 154)
+++ GNUnet/todo 2005-02-02 10:09:23 UTC (rev 155)
@@ -9,7 +9,7 @@
0.7.0pre0 [3'05] (aka "pre-preview"):
- Missing Features:
- * fsui core (persistence, shutdown, multiple FSUIs)
+ * fsui core (persistence, shutdown, multiple FSUIs) [ difficult ]
* mysql sqstore implementation iterator problem (Igor?)
- Need testing:
* ECRS-directories (build, iterate)
@@ -20,15 +20,11 @@
0.7.0pre1 [4'05] (aka "preview"):
- sqlite sqstore implementation does not compile yet (Nils)
-- gnunet-insert:
- * allow any kind of meta-data to be specified on the
- command-line
- gnunet-search:
- * dump directory with search results
- * 'handle' anonymity-level setting
+ * dump directory with search results [ easy ]
+ * 'handle' anonymity-level setting [ easy ]
- FS:
- * implement GetAvgPriority (fs.c)
- * DHT integration (fs.c)
+ * implement GetAvgPriority (fs.c) [ easy ]
- FSUI:
* download: various details wrt generated events
* namespace updates
@@ -36,16 +32,16 @@
0.7.0 [5'05] (aka "compatibility? what's that?"):
- Missing Features:
- * topology: do aggressive bootstrap on first start (Christian)
- * ecrs-unindex: code cleanup
+ * topology: do aggressive bootstrap on first start (Christian) [ easy ]
+ * ecrs-unindex: code cleanup [ easy ]
* fix dht routing service
- make dht respect new dht API (long way to go)
- - fs-dht integration
+ - fs-dht integration [ difficult ]
* configure.ac: flags for mysql, gmp, libgcrypt should ONLY be passed when
- linking the respective modules / libraries (gnunet_util, sqstore_mysql)
+ linking the respective modules / libraries (gnunet_util, sqstore_mysql) [
tricky ]
- Features removed but to be revived:
* fsui download: limit parallelism (currently unlimited, old gnunet-download
allowed
- user to specify maximum amount of parallelism)
+ user to specify maximum amount of parallelism) [ tricky ]
- Need testing:
* gnunet-dht-join and gnunet-dht-query
* gnunet-tracekit, -tbench, -chat
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r155 - in GNUnet: . src/applications/dht/module src/include,
grothoff <=