From: Bart Polot Date: Wed, 20 Jun 2012 16:57:11 +0000 (+0000) Subject: - complete block plugin, use block by put id X-Git-Tag: initial-import-from-subversion-38251~12918 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8fff1a5af6382f5dfbbb6cafc71907bb08fc96db;p=oweals%2Fgnunet.git - complete block plugin, use block by put id --- diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c index b6ff241d7..ef3f73f98 100644 --- a/src/mesh/gnunet-service-mesh_new.c +++ b/src/mesh/gnunet-service-mesh_new.c @@ -677,8 +677,8 @@ announce_application (void *cls, const struct GNUNET_HashCode * key, void *value GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE, - sizeof (struct PBlock), - &block, + sizeof (block), + (const char *) &block, GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), APP_ANNOUNCE_TIME), APP_ANNOUNCE_TIME, NULL, NULL); @@ -723,6 +723,8 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct PBlock block; + if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) { announce_id_task = GNUNET_SCHEDULER_NO_TASK; @@ -734,13 +736,15 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ DEBUG_DHT ("DHT_put for ID %s started.\n", GNUNET_i2s (&my_full_id)); + block.id = my_full_id; + block.type = htonl (0); GNUNET_DHT_put (dht_handle, /* DHT handle */ &my_full_id.hashPubKey, /* Key to use */ 10, /* Replication level */ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */ GNUNET_BLOCK_TYPE_MESH_PEER, /* Block type */ - sizeof (my_full_id), /* Size of the data */ - (char *) &my_full_id, /* Data itself */ + sizeof (block), /* Size of the data */ + (const char *) &block, /* Data itself */ GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */ GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ NULL, /* Continuation */ diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c index 8b601652f..7c5b9fbeb 100644 --- a/src/mesh/plugin_block_mesh.c +++ b/src/mesh/plugin_block_mesh.c @@ -127,16 +127,18 @@ block_plugin_mesh_get_key (void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_HashCode * key) { const struct PBlock *pb; + pb = block; switch (type) { case GNUNET_BLOCK_TYPE_MESH_PEER: if (sizeof (struct PBlock) != block_size) return GNUNET_SYSERR; - pb = block; *key = pb->id.hashPubKey; return GNUNET_OK; - // FIXME: other types... + case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE: + GNUNET_CRYPTO_hash (&pb->type, sizeof(GNUNET_MESH_ApplicationType), key); + return GNUNET_OK; default: return GNUNET_SYSERR; }