-no peerinfo IO on tests
[oweals/gnunet.git] / src / core / gnunet-core.c
index 4f49f81308407dbea1b82a796d5e4c7a49a5c897..37f1caec2e97de87b01505a7a12493efb24fedea 100644 (file)
@@ -44,6 +44,8 @@ static int monitor_connections_counter;
 
 static struct GNUNET_CORE_Handle *ch;
 
+static struct GNUNET_PeerIdentity my_id;
+
 /**
  * Task run in monitor mode when the user presses CTRL-C to abort.
  * Stops monitoring activity.
@@ -68,13 +70,9 @@ shutdown_task (void *cls,
  *
  * @param cls closure (unused)
  * @param peer peer identity this notification is about
- * @param atsi performance data for the connection
- * @param atsi_count number of records in 'atsi'
  */
 static void
-connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
-                         const struct GNUNET_ATS_Information *atsi,
-                         unsigned int atsi_count)
+connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct GNUNET_CRYPTO_HashAsciiEncoded enc;
 
@@ -84,6 +82,15 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
   printf (_("Peer `%s'\n"), (const char *) &enc);
 }
 
+void
+monitor_notify_startup (void *cls,
+                       struct GNUNET_CORE_Handle * server,
+                       const struct GNUNET_PeerIdentity *
+                       my_identity)
+{
+  my_id = (*my_identity);
+}
+
 
 /**
  * Function called to notify core users that another
@@ -91,23 +98,23 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
  *
  * @param cls closure
  * @param peer the peer that connected
- * @param ats performance data
- * @param ats_count number of entries in ats (excluding 0-termination)
  */
 static void
-monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
-                const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
+monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  monitor_connections_counter ++;
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
-  char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-  FPRINTF (stdout, _("%24s: %-17s %4s   (%u connections in total)\n"),
-           now_str,
-           _("Connected to"),
-           GNUNET_i2s (peer),
-           monitor_connections_counter);
-
-  GNUNET_free (now_str);
+  const char *now_str;
+
+  if (0 != memcmp (&my_id, peer, sizeof (my_id)))
+  {
+    monitor_connections_counter ++;
+    now_str = GNUNET_STRINGS_absolute_time_to_string (now);
+    FPRINTF (stdout, _("%24s: %-17s %4s   (%u connections in total)\n"),
+             now_str,
+             _("Connected to"),
+             GNUNET_i2s (peer),
+             monitor_connections_counter);
+  }
 }
 
 
@@ -122,17 +129,20 @@ static void
 monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
-  char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-
-  GNUNET_assert (monitor_connections_counter > 0);
-  monitor_connections_counter --;
+  const char *now_str;
 
-  FPRINTF (stdout, _("%24s: %-17s %4s   (%u connections in total)\n"),
-           now_str,
-           _("Disconnected from"),
-           GNUNET_i2s (peer),
-           monitor_connections_counter);
-  GNUNET_free (now_str);
+  if (0 != memcmp (&my_id, peer, sizeof (my_id)))
+  {
+    now_str = GNUNET_STRINGS_absolute_time_to_string (now);
+
+    GNUNET_assert (monitor_connections_counter > 0);
+    monitor_connections_counter--;
+    FPRINTF (stdout, _("%24s: %-17s %4s   (%u connections in total)\n"),
+             now_str,
+             _("Disconnected from"),
+             GNUNET_i2s (peer),
+             monitor_connections_counter);
+  }
 }
 
 
@@ -149,6 +159,9 @@ static void
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  static const struct GNUNET_CORE_MessageHandler handlers[] = {
+    {NULL, 0, 0}
+  };
   if (args[0] != NULL)
   {
     FPRINTF (stderr, _("Invalid command line argument `%s'\n"), args[0]);
@@ -158,11 +171,9 @@ run (void *cls, char *const *args, const char *cfgfile,
     GNUNET_CORE_iterate_peers (cfg, &connected_peer_callback, NULL);
   else
   {
-    const static struct GNUNET_CORE_MessageHandler handlers[] = {
-      {NULL, 0, 0}
-    };
-
-    ch = GNUNET_CORE_connect (cfg, NULL, NULL,
+    memset(&my_id, '\0', sizeof (my_id));
+    ch = GNUNET_CORE_connect (cfg, NULL,
+                              monitor_notify_startup,
                               monitor_notify_connect,
                               monitor_notify_disconnect,
                               NULL, GNUNET_NO,