- debug
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_dht.c
index 3beb2da8a85bc3bebe822a8a8166badfd44ccb4d..63f98a4d743678ee9b7230472a9dabe143f97d4c 100644 (file)
@@ -25,6 +25,7 @@
 #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"
@@ -61,6 +62,16 @@ struct GMD_search_handle
  */
 extern struct GNUNET_STATISTICS_Handle *stats;
 
+/**
+ * Own ID (short value).
+ */
+extern GNUNET_PEER_Id myid;
+
+/**
+ * Own ID (full value).
+ */
+extern struct GNUNET_PeerIdentity my_full_id;
+
 /**
  * Handle to use DHT.
  */
@@ -81,21 +92,6 @@ static unsigned long long dht_replication_level;
  */
 static GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
 
-/**
- * Own ID (short value).
- */
-static GNUNET_PEER_Id short_id;
-
-/**
- * Own ID (full value).
- */
-static struct GNUNET_PeerIdentity *full_id;
-
-/**
- * Own private key.
- */
-static struct GNUNET_CRYPTO_EccPrivateKey *private_key;
-
 
 /******************************************************************************/
 /********************************   STATIC  ***********************************/
@@ -248,8 +244,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
    * - Set data expiration in function of X
    * - Adapt X to churn
    */
-  block.id = *full_id;
-  GNUNET_CRYPTO_hash (full_id, sizeof (struct GNUNET_PeerIdentity), &phash);
+  block.id = my_full_id;
+  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 */
@@ -277,15 +273,14 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @param peer_id Local peer ID (must remain valid during all execution time).
  */
 void
-GMD_init (const struct GNUNET_CONFIGURATION_Handle *c,
-          struct GNUNET_PeerIdentity *peer_id)
+GMD_init (const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  full_id = peer_id;
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DHT_REPLICATION_LEVEL",
                                              &dht_replication_level))
   {
-    LOG_config_invalid (GNUNET_ERROR_TYPE_WARNING,
+    GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
                                "MESH", "DHT_REPLICATION_LEVEL", "USING DEFAULT");
     dht_replication_level = 3;
   }
@@ -294,7 +289,7 @@ GMD_init (const struct GNUNET_CONFIGURATION_Handle *c,
       GNUNET_CONFIGURATION_get_value_time (c, "MESH", "ID_ANNOUNCE_TIME",
                                            &id_announce_time))
   {
-    LOG_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                "MESH", "ID_ANNOUNCE_TIME", "MISSING");
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -339,6 +334,7 @@ GMD_search (const struct GNUNET_PeerIdentity *peer_id,
        "  Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
   GNUNET_CRYPTO_hash (peer_id, sizeof (struct GNUNET_PeerIdentity), &phash);
   h = GNUNET_new (struct GMD_search_handle);
+  h->callback = callback;
   h->cls = cls;
   h->dhtget = GNUNET_DHT_get_start (dht_handle,    /* handle */
                                     GNUNET_BLOCK_TYPE_MESH_PEER, /* type */