Use DHT_HELLO for MESH peer discovery, benefit from wider replication
authorBart Polot <bart@net.in.tum.de>
Wed, 5 Feb 2014 17:24:23 +0000 (17:24 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 5 Feb 2014 17:24:23 +0000 (17:24 +0000)
src/mesh/Makefile.am
src/mesh/gnunet-service-mesh_dht.c

index 35f06f8d2eeae8b429f856b8c8ab2bca71e29e6a..2775dff6c284bd09f84bad26396efbee21e7295a 100644 (file)
@@ -29,21 +29,6 @@ bin_PROGRAMS = \
 lib_LTLIBRARIES = \
   libgnunetmesh.la $(EXP_LIB)
 
-plugin_LTLIBRARIES = \
- libgnunet_plugin_block_mesh.la
-
-libgnunet_plugin_block_mesh_la_SOURCES = \
- plugin_block_mesh.c
-libgnunet_plugin_block_mesh_la_LIBADD = \
- $(top_builddir)/src/block/libgnunetblock.la \
- $(top_builddir)/src/util/libgnunetutil.la
-libgnunet_plugin_block_mesh_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_block_mesh_la_DEPENDENCIES = \
- $(top_builddir)/src/block/libgnunetblock.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-
 libgnunetmesh_la_SOURCES = \
   mesh_api.c mesh_common.c
 libgnunetmesh_la_LIBADD = \
index 0e27eb9fa92e27ba7087779e48308afd03efa65e..9bed8f40a0f7cc989e2d0a5cd8476f3f111ed4d1 100644 (file)
 #include "gnunet_dht_service.h"
 #include "gnunet_statistics_service.h"
 
-#include "block_mesh.h"
 #include "mesh_path.h"
 #include "gnunet-service-mesh_dht.h"
 #include "gnunet-service-mesh_peer.h"
+#include "gnunet-service-mesh_hello.h"
 
 #define LOG(level, ...) GNUNET_log_from (level,"mesh-dht",__VA_ARGS__)
 
@@ -240,8 +240,9 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
 static void
 announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct PBlock block;
   struct GNUNET_HashCode phash;
+  struct GNUNET_HELLO_Message *hello;
+  size_t size;
 
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
   {
@@ -253,15 +254,16 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
    * - Set data expiration in function of X
    * - Adapt X to churn
    */
-  block.id = my_full_id;
+  hello = GMH_get_mine ();
+  size = GNUNET_HELLO_size (hello);
   GNUNET_CRYPTO_hash (&my_full_id, sizeof (struct GNUNET_PeerIdentity), &phash);
   GNUNET_DHT_put (dht_handle,   /* DHT handle */
                   &phash,       /* Key to use */
                   dht_replication_level,     /* Replication level */
                   GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,    /* DHT options */
-                  GNUNET_BLOCK_TYPE_MESH_PEER,       /* Block type */
-                  sizeof (block),  /* Size of the data */
-                  (const char *) &block, /* Data itself */
+                  GNUNET_BLOCK_TYPE_DHT_HELLO,       /* Block type */
+                  size,  /* Size of the data */
+                  (const char *) hello, /* Data itself */
                   GNUNET_TIME_UNIT_FOREVER_ABS,  /* Data expiration */
                   GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
                   NULL,         /* Continuation */
@@ -364,13 +366,14 @@ GMD_search (const struct GNUNET_PeerIdentity *peer_id,
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "  Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
-  GNUNET_CRYPTO_hash (peer_id, sizeof (struct GNUNET_PeerIdentity), &phash);
+  memset (&phash, 0, sizeof (phash));
+  memcpy (&phash, &my_full_id, sizeof (my_full_id));
   h = GNUNET_new (struct GMD_search_handle);
   h->peer_id = GNUNET_PEER_intern (peer_id);
   h->callback = callback;
   h->cls = cls;
   h->dhtget = GNUNET_DHT_get_start (dht_handle,    /* handle */
-                                    GNUNET_BLOCK_TYPE_MESH_PEER, /* type */
+                                    GNUNET_BLOCK_TYPE_DHT_HELLO, /* type */
                                     &phash,     /* key to search */
                                     dht_replication_level, /* replication level */
                                     GNUNET_DHT_RO_RECORD_ROUTE |