more stats
authorChristian Grothoff <christian@grothoff.org>
Sat, 13 Mar 2010 11:17:04 +0000 (11:17 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 13 Mar 2010 11:17:04 +0000 (11:17 +0000)
TODO
src/Makefile.am
src/peerinfo/Makefile.am
src/peerinfo/gnunet-service-peerinfo.c

diff --git a/TODO b/TODO
index e0022741a494ace9b67afdb92b5c88955de244be..d5ffde68e618077e203d1e3e264b66d298e13c9b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -33,7 +33,6 @@ away), in order in which they will likely be done:
   - synchronous/asynchronous API (& implementation) is not nice;
     => provide notification-based API
   - does not seem to work with timeouts (especially if service is not running)
-  - add stats to peerinfo (# peers tracked)
   - add stats to fs service (# queries, # replies, # routed, # found, # pending)
   - add stats to dvstore (# bytes available, # bytes used, # PUTs, # GETs, # GETs satisfied)
 * ARM:
index 11912b2e2d8401d133cc5ded04e5ddda2698fcf7..4d63bc756b2fed23f3605a4a0f82d359d7fc5eb1 100644 (file)
@@ -14,10 +14,10 @@ endif
 SUBDIRS = \
   include $(INTLEMU_SUBDIRS) \
   util \
+  statistics \
   arm \
   hello \
   peerinfo \
-  statistics \
   datacache \
   datastore \
   template \
index 7512552d0238653bcd6443814d1d060a731c93a6..ea7ef1316d140583f2b996fd82797e69fac19a03 100644 (file)
@@ -36,6 +36,7 @@ gnunet_service_peerinfo_SOURCES = \
  gnunet-service-peerinfo.c         
 gnunet_service_peerinfo_LDADD = \
   $(top_builddir)/src/hello/libgnunethello.la \
+  $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 
index 703ebee4c5bcb033154df81451ac2ae85e5166ba..b23d3318e6a5964e703ca19147574c5cb8dc6daa 100644 (file)
@@ -37,6 +37,7 @@
 #include "gnunet_hello_lib.h"
 #include "gnunet_protocols.h"
 #include "gnunet_service_lib.h"
+#include "gnunet_statistics_service.h"
 #include "peerinfo.h"
 
 /**
@@ -108,6 +109,11 @@ static char *networkIdDirectory;
  */
 static char *trustDirectory;
 
+/**
+ * Handle for reporting statistics.
+ */
+static struct GNUNET_STATISTICS_Handle *stats;
+
 
 /**
  * Notify all clients in the notify list about the
@@ -251,6 +257,10 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
   entry = lookup_host_entry (identity);
   if (entry != NULL)
     return;
+  GNUNET_STATISTICS_update (stats,
+                           gettext_noop ("# peers known"),
+                           1,
+                           GNUNET_NO);
   entry = GNUNET_malloc (sizeof (struct HostEntry));
   entry->identity = *identity;
   fn = get_trust_filename (identity);
@@ -763,6 +773,11 @@ shutdown_task (void *cls,
 {
   GNUNET_SERVER_notification_context_destroy (notify_list);
   notify_list = NULL;
+  if (stats != NULL)
+    {
+      GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
+      stats = NULL;
+    }
 }
 
 
@@ -780,6 +795,7 @@ run (void *cls,
      struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  stats = GNUNET_STATISTICS_create (sched, "statistics", cfg);
   notify_list = GNUNET_SERVER_notification_context_create (server, 0);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONFIGURATION_get_value_filename (cfg,