- debug
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_dht.c
index e09c6b65e41aebe974057be79ab29b420a7c3668..63f98a4d743678ee9b7230472a9dabe143f97d4c 100644 (file)
@@ -23,7 +23,9 @@
 #include "gnunet_util_lib.h"
 
 #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"
@@ -56,39 +58,39 @@ struct GMD_search_handle
 /******************************************************************************/
 
 /**
- * Handle to use DHT.
+ * Global handle to the statistics service.
  */
-static struct GNUNET_DHT_Handle *dht_handle;
+extern struct GNUNET_STATISTICS_Handle *stats;
 
 /**
- * How often to PUT own ID in the DHT.
+ * Own ID (short value).
  */
-static struct GNUNET_TIME_Relative id_announce_time;
+extern GNUNET_PEER_Id myid;
 
 /**
- * DHT replication level, see DHT API: GNUNET_DHT_get_start, GNUNET_DHT_put.
+ * Own ID (full value).
  */
-static unsigned long long dht_replication_level;
+extern struct GNUNET_PeerIdentity my_full_id;
 
 /**
- * Task to periodically announce itself in the network.
+ * Handle to use DHT.
  */
-static GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
+static struct GNUNET_DHT_Handle *dht_handle;
 
 /**
- * Own ID (short value).
+ * How often to PUT own ID in the DHT.
  */
-static GNUNET_PEER_Id short_id;
+static struct GNUNET_TIME_Relative id_announce_time;
 
 /**
- * Own ID (full value).
+ * DHT replication level, see DHT API: GNUNET_DHT_get_start, GNUNET_DHT_put.
  */
-static struct GNUNET_PeerIdentity *full_id;
+static unsigned long long dht_replication_level;
 
 /**
- * Own private key.
+ * Task to periodically announce itself in the network.
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *private_key;
+static GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
 
 
 /******************************************************************************/
@@ -242,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 */
@@ -271,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;
   }
@@ -288,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;
@@ -333,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 */