[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5009 - in GNUnet: . src/applications/fs/ecrs src/applicati
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5009 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/namespace src/applications/fs/tools src/include |
Date: |
Sun, 10 Jun 2007 19:39:02 -0600 (MDT) |
Author: grothoff
Date: 2007-06-10 19:39:00 -0600 (Sun, 10 Jun 2007)
New Revision: 5009
Modified:
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/fsui/search.c
GNUnet/src/applications/fs/namespace/namespace_info.c
GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
GNUnet/src/include/gnunet_namespace_lib.h
GNUnet/todo
Log:
cleaner code for tracking namespace roots
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2007-06-10 22:43:30 UTC (rev
5008)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2007-06-11 01:39:00 UTC (rev
5009)
@@ -275,10 +275,11 @@
&knb->nblock,
size - sizeof(KBlock) - sizeof(unsigned int));
- GE_ASSERT(ectx, OK == sign(pk,
- sizeof(NBlock) + mdsize,
- &knb->nblock,
- &knb->kblock.signature));
+ GE_ASSERT(ectx,
+ OK == sign(pk,
+ sizeof(NBlock) + mdsize,
+ &knb->nblock,
+ &knb->kblock.signature));
/* extra check: verify sig */
freePrivateKey(pk);
if (OK != FS_insert(sock, knvalue)) {
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2007-06-10 22:43:30 UTC (rev
5008)
+++ GNUnet/src/applications/fs/fsui/search.c 2007-06-11 01:39:00 UTC (rev
5009)
@@ -37,9 +37,6 @@
#define DEBUG_SEARCH NO
-/* must match namespace_info.c */
-#define NS_ROOTS "data" DIR_SEPARATOR_STR "namespace-root" DIR_SEPARATOR_STR
-
/**
* Pass the result to the client and note it as shown.
*/
@@ -68,48 +65,7 @@
URITRACK_SEARCH_RESULT);
}
-static void setNamespaceRoot(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const ECRS_FileInfo * fi) {
- char * fn;
- char * fnBase;
- HashCode512 ns;
- char * name;
- if (OK != ECRS_getNamespaceId(fi->uri,
- &ns)) {
- GE_BREAK(ectx, 0);
- return;
- }
- name = ECRS_getNamespaceName(&ns);
- GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
- fn = MALLOC(strlen(fnBase) +
- strlen(NS_ROOTS) +
- strlen(name) +
- 6);
- strcpy(fn, fnBase);
- strcat(fn, DIR_SEPARATOR_STR);
- strcat(fn, NS_ROOTS);
- disk_directory_create(ectx, fn);
- strcat(fn, DIR_SEPARATOR_STR);
- strcat(fn, name);
- FREE(name);
- FREE(fnBase);
- if (OK == ECRS_getSKSContentHash(fi->uri,
- &ns)) {
- disk_file_write(ectx,
- fn,
- &ns,
- sizeof(HashCode512),
- "644");
- }
- FREE(fn);
-}
-
/**
* Process results found by ECRS.
*/
@@ -129,9 +85,9 @@
pos->ctx->cfg,
fi);
if (isRoot) {
- setNamespaceRoot(ectx,
- pos->ctx->cfg,
- fi);
+ NS_setNamespaceRoot(ectx,
+ pos->ctx->cfg,
+ fi->uri);
NS_addNamespaceInfo(ectx,
pos->ctx->cfg,
fi->uri,
@@ -198,9 +154,10 @@
rp->matchingKeyCount+1);
rp->matchingKeys[rp->matchingKeyCount-1] = *key;
#if DEBUG_SEARCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result (waiting for more %u keys before showing
client).\n",
- pos->numberOfURIKeys - rp->matchingKeyCount);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result (waiting for more %u keys before
showing client).\n",
+ pos->numberOfURIKeys - rp->matchingKeyCount);
#endif
return OK;
}
Modified: GNUnet/src/applications/fs/namespace/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_info.c 2007-06-10
22:43:30 UTC (rev 5008)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c 2007-06-11
01:39:00 UTC (rev 5009)
@@ -40,7 +40,6 @@
struct DiscoveryCallback * next;
NS_NamespaceIterator callback;
void * closure;
- int local;
};
static struct DiscoveryCallback * head;
@@ -53,19 +52,17 @@
static void internal_notify(const char * name,
const HashCode512 * id,
const struct ECRS_MetaData * md,
- int rating,
- int local) {
+ int rating) {
struct DiscoveryCallback * pos;
MUTEX_LOCK(lock);
pos = head;
while (pos != NULL) {
- if (pos->local == local)
- pos->callback(pos->closure,
- name,
- id,
- md,
- rating);
+ pos->callback(pos->closure,
+ name,
+ id,
+ md,
+ rating);
pos = pos->next;
}
MUTEX_UNLOCK(lock);
@@ -205,7 +202,7 @@
* for a while since it must create a public-private key pair!
*
* @param meta meta-data about the namespace (maybe NULL)
- * @return URI on success, NULL on error (namespace already exists)
+ * @return namespace root URI on success, NULL on error (namespace already
exists)
*/
struct ECRS_URI *
NS_createNamespace(struct GE_Context * ectx,
@@ -232,7 +229,10 @@
if (ret != NULL) {
HashCode512 id;
char * name;
-
+
+ NS_setNamespaceRoot(ectx,
+ cfg,
+ ret);
ECRS_getNamespaceId(ret,
&id);
name = ECRS_getNamespaceName(&id);
@@ -244,8 +244,7 @@
internal_notify(namespaceName,
&id,
meta,
- 0,
- YES);
+ 0);
FREE(name);
}
return ret;
@@ -388,52 +387,50 @@
}
/**
- * List all available (local or non-local) namespaces.
+ * List all available (local and non-local) namespaces.
*
- * @param local only list local namespaces (if NO, only
- * non-local known namespaces are listed)
*/
int NS_listNamespaces(struct GE_Context * ectx,
struct GC_Configuration * cfg,
- int local,
NS_NamespaceIterator iterator,
void * closure) {
LNClosure cls;
- int ret;
+ char * fn;
+ char * fnBase;
+ int ret1;
+ int ret2;
cls.iterator = iterator;
cls.closure = closure;
cls.ectx = ectx;
cls.cfg = cfg;
- if (local == YES) {
- ret = ECRS_listNamespaces(ectx,
- cfg,
- &localListNamespaceHelper,
- &cls);
- } else {
- char * fn;
- char * fnBase;
-
- GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
- fn = MALLOC(strlen(fnBase) +
- strlen(NS_DIR) +
- 4);
- strcpy(fn, fnBase);
- FREE(fnBase);
- strcat(fn, DIR_SEPARATOR_STR);
- strcat(fn, NS_DIR);
- disk_directory_create(ectx, fn);
- ret = disk_directory_scan(ectx,
- fn,
- &listNamespaceHelper,
- &cls);
- FREE(fn);
- }
- return ret;
+ ret1 = ECRS_listNamespaces(ectx,
+ cfg,
+ &localListNamespaceHelper,
+ &cls);
+ if (ret1 == -1)
+ return ret1;
+ GC_get_configuration_value_filename(cfg,
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
+ fn = MALLOC(strlen(fnBase) +
+ strlen(NS_DIR) +
+ 4);
+ strcpy(fn, fnBase);
+ FREE(fnBase);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, NS_DIR);
+ disk_directory_create(ectx, fn);
+ ret2 = disk_directory_scan(ectx,
+ fn,
+ &listNamespaceHelper,
+ &cls);
+ FREE(fn);
+ if (ret2 == -1)
+ return ret2;
+ return ret1 + ret2;
}
/**
@@ -961,8 +958,10 @@
ECRS_getNamespaceId(uri,
&id);
name = ECRS_getNamespaceName(&id);
- if (name == NULL)
+ if (name == NULL) {
+ GE_BREAK(ectx, 0);
return;
+ }
ranking = 0;
if (OK == readNamespaceInfo(ectx,
cfg,
@@ -979,17 +978,16 @@
ranking);
ECRS_freeMetaData(old);
} else {
- internal_notify(name,
- &id,
- meta,
- ranking,
- NO);
writeNamespaceInfo(ectx,
cfg,
name,
meta,
ranking);
}
+ internal_notify(name,
+ &id,
+ meta,
+ ranking);
FREE(name);
}
@@ -1034,13 +1032,54 @@
return ret;
}
+void NS_setNamespaceRoot(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri) {
+ char * fn;
+ char * fnBase;
+ HashCode512 ns;
+ char * name;
+
+ if (OK != ECRS_getNamespaceId(uri,
+ &ns)) {
+ GE_BREAK(ectx, 0);
+ return;
+ }
+ name = ECRS_getNamespaceName(&ns);
+ GC_get_configuration_value_filename(cfg,
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
+ fn = MALLOC(strlen(fnBase) +
+ strlen(NS_ROOTS) +
+ strlen(name) +
+ 6);
+ strcpy(fn, fnBase);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, NS_ROOTS);
+ disk_directory_create(ectx, fn);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, name);
+ FREE(name);
+ FREE(fnBase);
+ if (OK == ECRS_getSKSContentHash(uri,
+ &ns)) {
+ disk_file_write(ectx,
+ fn,
+ &ns,
+ sizeof(HashCode512),
+ "644");
+ }
+ FREE(fn);
+}
+
/**
* Register callback to be invoked whenever we discover
* a new namespace.
*/
int NS_registerDiscoveryCallback(struct GE_Context * ectx,
struct GC_Configuration * cfg,
- int local,
NS_NamespaceIterator iterator,
void * closure) {
struct DiscoveryCallback * list;
@@ -1048,13 +1087,11 @@
list = MALLOC(sizeof(struct DiscoveryCallback));
list->callback = iterator;
list->closure = closure;
- list->local = local;
MUTEX_LOCK(lock);
list->next = head;
head = list;
NS_listNamespaces(ectx,
cfg,
- local,
iterator,
closure);
MUTEX_UNLOCK(lock);
Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-06-10 22:43:30 UTC
(rev 5008)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-06-11 01:39:00 UTC
(rev 5009)
@@ -308,7 +308,6 @@
/* print information about pseudonyms */
cnt = NS_listNamespaces(ectx,
cfg,
- NO,
&namespacePrinter,
NULL);
if (cnt == -1)
Modified: GNUnet/src/include/gnunet_namespace_lib.h
===================================================================
--- GNUnet/src/include/gnunet_namespace_lib.h 2007-06-10 22:43:30 UTC (rev
5008)
+++ GNUnet/src/include/gnunet_namespace_lib.h 2007-06-11 01:39:00 UTC (rev
5009)
@@ -131,16 +131,15 @@
const char * ns,
HashCode512 * root);
+void NS_setNamespaceRoot(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri);
/**
* List all available (local or non-local) namespaces.
- *
- * @param local only list local namespaces (if NO, only
- * non-local known namespaces are listed)
*/
int NS_listNamespaces(struct GE_Context * ectx,
struct GC_Configuration * cfg,
- int local,
NS_NamespaceIterator iterator,
void * closure); /* namespace_info.c */
/**
@@ -149,7 +148,6 @@
*/
int NS_registerDiscoveryCallback(struct GE_Context * ectx,
struct GC_Configuration * cfg,
- int local,
NS_NamespaceIterator iterator,
void * closure);
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2007-06-10 22:43:30 UTC (rev 5008)
+++ GNUnet/todo 2007-06-11 01:39:00 UTC (rev 5009)
@@ -19,6 +19,7 @@
* support NAT-PMP (in addition to UPnP)
* add bloomfilter to dstore
* asynchronous (or client-side?) DNS resolution (for peer-info stuff)
+ => use GNU adns library?
- Documentation:
* LJ article
- Testcases:
@@ -33,6 +34,7 @@
See also: https://gnunet.org/drupal/?q=node/97 [RC]
- guard friendly connection count (#1018) [RC]
- power insert [#854]
+- have a way to clean up namespace information
1.0.0 (aka "userfriendly"):
- implement testbed for profiling
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5009 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/namespace src/applications/fs/tools src/include,
gnunet <=