#include "gnunet_core_service.h"
#include "gnunet_protocols.h"
#include "gnunet_peerinfo_service.h"
+#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_util_lib.h"
*/
static struct PeerList *peers;
+/**
+ * Handle for reporting statistics.
+ */
+static struct GNUNET_STATISTICS_Handle *stats;
+
/**
* Flag to disallow non-friend connections (pure F2F mode).
*/
{
struct DisconnectList *dl = cls;
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers blacklisted"),
+ 1,
+ GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (disconnect_head,
disconnect_tail,
dl);
struct PeerList *pl = cls;
pl->wh = NULL;
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers blacklisted"),
+ -1,
+ GNUNET_NO);
}
"Asking core to connect to `%s'\n",
GNUNET_i2s (&pos->id));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# connect requests issued to core"),
+ 1,
+ GNUNET_NO);
pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg,
GNUNET_TIME_UNIT_MINUTES,
&pos->id,
GNUNET_i2s (peer));
#endif
connection_count++;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# peers connected"),
+ connection_count,
+ GNUNET_NO);
pos = find_peer (peer);
if (pos == NULL)
{
(GNUNET_YES != friends_only) )
whitelist_peers ();
friend_count++;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# friends connected"),
+ connection_count,
+ GNUNET_NO);
}
reschedule_hellos (pos);
}
return;
}
connection_count--;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# peers connected"),
+ connection_count,
+ GNUNET_NO);
if (pos->is_friend)
- friend_count--;
+ {
+ friend_count--;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# friends connected"),
+ connection_count,
+ GNUNET_NO);
+ }
if ( (connection_count < target_connection_count) ||
(friend_count < minimum_friend_count) )
try_add_peers ();
}
GNUNET_free (data);
GNUNET_free (fn);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# friends in configuration"),
+ entries_found,
+ GNUNET_NO);
if ( (minimum_friend_count > entries_found) &&
(friends_only == GNUNET_NO) )
{
"HELLO",
GNUNET_i2s (other));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# HELLO messages received"),
+ 1,
+ GNUNET_NO);
if (transport != NULL)
GNUNET_TRANSPORT_offer_hello (transport,
message);
(unsigned int) want,
"HELLO");
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# HELLO messages gossipped"),
+ 1,
+ GNUNET_NO);
}
}
pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY);
GNUNET_TRANSPORT_blacklist_cancel (dl->rh);
GNUNET_free (dl);
}
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
+ stats = NULL;
+ }
}
sched = s;
cfg = c;
+ stats = GNUNET_STATISTICS_create (sched, "topology", cfg);
autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg,
"TOPOLOGY",
"AUTOCONNECT");