- don-t re-scheduler, destroy immediately (comes from scheduler)
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_hello.c
index bddd2fe5a1b4d72e48d5c3b280ffce0c0b8ad81c..723989bf8b473bd55e576c7e8b926eba4b1bb7d2 100644 (file)
@@ -88,10 +88,10 @@ struct GNUNET_PEERINFO_NotifyContext* nc;
 /**
  * Process each hello message received from peerinfo.
  *
- * @param cls the 'struct GetUriContext'
- * @param peer identity of the peer
- * @param hello addresses of the peer
- * @param err_msg error message
+ * @param cls Closure (unused).
+ * @param peer Identity of the peer.
+ * @param hello Hello of the peer.
+ * @param err_msg Error message.
  */
 static void
 got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
@@ -100,11 +100,27 @@ got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
 {
   struct MeshPeer *peer;
 
-  if (NULL == id)
-    LOG (GNUNET_ERROR_TYPE_ERROR, "not a valid id\n");
-
+  if (NULL == id || NULL == hello)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, " hello with id %p and msg %p\n", id, hello);
+    return;
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, " hello for %s (%d bytes), expires on %s\n",
+       GNUNET_i2s (id), NULL != hello ? GNUNET_HELLO_size (hello) : -1,
+       GNUNET_STRINGS_absolute_time_to_string (GNUNET_HELLO_get_last_expiration(hello)));
+  if (NULL == hello)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, " hello is NULL\n");
+    return;
+  }
   peer = GMP_get (id);
   GMP_set_hello (peer, hello);
+
+  if (GMP_get_short_id (peer) == myid)
+  {
+    mine = GMP_get_hello (peer);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, " updated mine to %p\n", mine);
+  }
 }
 
 
@@ -121,7 +137,7 @@ void
 GMH_init (const struct GNUNET_CONFIGURATION_Handle *c)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
-  GNUNET_assert (NULL != nc);
+  GNUNET_assert (NULL == nc);
   peerinfo = GNUNET_PEERINFO_connect (c);
   nc = GNUNET_PEERINFO_notify (c, GNUNET_NO, &got_hello, NULL);
 }
@@ -154,6 +170,7 @@ GMH_shutdown ()
 const struct GNUNET_HELLO_Message *
 GMH_get_mine (void)
 {
+  LOG (GNUNET_ERROR_TYPE_DEBUG, " mine is %p\n", mine);
   return mine;
 }
 
@@ -177,7 +194,7 @@ GMH_get (const struct GNUNET_PeerIdentity *id)
  *
  * @param h Hello message.
  */
-void
+char *
 GMH_2s (const struct GNUNET_HELLO_Message *h)
 {
   return "hello (TODO)";