additional stats on peers connected
authorNathan S. Evans <evans@in.tum.de>
Wed, 22 Jun 2011 14:03:51 +0000 (14:03 +0000)
committerNathan S. Evans <evans@in.tum.de>
Wed, 22 Jun 2011 14:03:51 +0000 (14:03 +0000)
src/dht/dht.h
src/dht/gnunet-service-dht.c

index ed24c19bba97f62259016d16b81613fb41ca422f..6881b61ed02eb197a106df51229c1bab69ea084f 100644 (file)
@@ -83,6 +83,7 @@
 #define STAT_DISCONNECTS "# Disconnects received"
 #define STAT_DUPLICATE_UID "# Duplicate UID's encountered (bad if any!)"
 #define STAT_RECENT_SEEN "# recent requests seen again (routing loops, alternate paths)"
+#define STAT_PEERS_KNOWN "# DHT Peers known"
 
 
 /**
index 61044549beac1532ccf07b69be59d373697999aa..d71f9ce502f56eb4b281ce635ce4a8fa7eca89bc 100644 (file)
@@ -1044,6 +1044,15 @@ increment_stats (const char *value)
     }
 }
 
+static void
+decrement_stats (const char *value)
+{
+  if (stats != NULL)
+    {
+      GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO);
+    }
+}
+
 /**
  *  Try to send another message from our core send list
  */
@@ -1644,6 +1653,7 @@ delete_peer (struct PeerInfo *peer, unsigned int bucket)
                                                        &peer->id.hashPubKey,
                                                        peer));
   GNUNET_free (peer);
+  decrement_stats(STAT_PEERS_KNOWN);
 }
 
 
@@ -5230,7 +5240,9 @@ handle_core_connect (void *cls,
       GNUNET_CONTAINER_multihashmap_put (all_known_peers, &peer->hashPubKey,
                                          ret,
                                          GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+      increment_stats(STAT_PEERS_KNOWN);
     }
+
 #if DEBUG_DHT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "%s:%s Adding peer to routing list: %s\n", my_short_id, "DHT",