From f08812fba40c96f2447c05c98ad54216c29bcb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 10 Nov 2017 16:34:36 +0100 Subject: [PATCH] Move total into stats. --- demo/main.c | 8 +++----- include/neocomm.h | 10 ++-------- src/node.cpp | 6 +----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/demo/main.c b/demo/main.c index 165320b..0603a9d 100644 --- a/demo/main.c +++ b/demo/main.c @@ -23,7 +23,6 @@ void print_help() { puts("Use `/' at the beginning to indicate a command (like in IRC)."); puts(" stats -- Give network statistics of the local node."); - puts(" num_nodes -- Get total number of nodes."); puts(" exit | quit -- Close the program."); puts(" help -- Show this help information."); } @@ -63,14 +62,13 @@ int main(int argc, char *argv[]) { else if(strcmp(in, "/stats") == 0) { struct stats statistics = NeoComm_get_node_stats(); - printf("Good: %u\nDubious: %u\nCached: %u\nIncoming: %u\n", + printf("Good: %u\nDubious: %u\nCached: %u\nIncoming: %u\nTotal: %u\n", statistics.good, statistics.dubious, statistics.cached, - statistics.incoming); + statistics.incoming, + statistics.total); } - else if(strcmp(in, "/num_nodes") == 0) - printf("%u", NeoComm_count_connected_nodes()); else if(strcmp(in, "/help") == 0) print_help(); } diff --git a/include/neocomm.h b/include/neocomm.h index 4af3dde..a8928a2 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -56,7 +56,8 @@ struct stats { unsigned int good, dubious, cached, - incoming; + incoming, + total; }; /** @@ -122,13 +123,6 @@ int NeoComm_export_nodes(const char *node_file); */ struct stats NeoComm_get_node_stats(); -/** - * @brief Get the number of nodes connected. - * - * @return A number of the known nodes. - */ -unsigned int NeoComm_count_connected_nodes(); - /** * @brief Join a channel. * diff --git a/src/node.cpp b/src/node.cpp index 9862127..77143cd 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -113,13 +113,9 @@ int NeoComm_export_nodes(const char *node_file) { return 1; } -unsigned int NeoComm_count_connected_nodes() { - return node.getNodesStats(AF_UNSPEC).getKnownNodes(); -} - struct stats NeoComm_get_node_stats() { struct stats statistics; - node.getNodesStats( + statistics.total = node.getNodesStats( AF_UNSPEC, &statistics.good, &statistics.dubious,