Move total into stats.

This commit is contained in:
Nicolás Ortega Froysa 2017-11-10 16:34:36 +01:00
parent 64fbe3ec9c
commit f08812fba4
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
3 changed files with 6 additions and 18 deletions

View File

@ -23,7 +23,6 @@
void print_help() { void print_help() {
puts("Use `/' at the beginning to indicate a command (like in IRC)."); puts("Use `/' at the beginning to indicate a command (like in IRC).");
puts(" stats -- Give network statistics of the local node."); puts(" stats -- Give network statistics of the local node.");
puts(" num_nodes -- Get total number of nodes.");
puts(" exit | quit -- Close the program."); puts(" exit | quit -- Close the program.");
puts(" help -- Show this help information."); puts(" help -- Show this help information.");
} }
@ -63,14 +62,13 @@ int main(int argc, char *argv[]) {
else if(strcmp(in, "/stats") == 0) else if(strcmp(in, "/stats") == 0)
{ {
struct stats statistics = NeoComm_get_node_stats(); 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.good,
statistics.dubious, statistics.dubious,
statistics.cached, 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) else if(strcmp(in, "/help") == 0)
print_help(); print_help();
} }

View File

@ -56,7 +56,8 @@ struct stats {
unsigned int good, unsigned int good,
dubious, dubious,
cached, cached,
incoming; incoming,
total;
}; };
/** /**
@ -122,13 +123,6 @@ int NeoComm_export_nodes(const char *node_file);
*/ */
struct stats NeoComm_get_node_stats(); 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. * @brief Join a channel.
* *

View File

@ -113,13 +113,9 @@ int NeoComm_export_nodes(const char *node_file) {
return 1; return 1;
} }
unsigned int NeoComm_count_connected_nodes() {
return node.getNodesStats(AF_UNSPEC).getKnownNodes();
}
struct stats NeoComm_get_node_stats() { struct stats NeoComm_get_node_stats() {
struct stats statistics; struct stats statistics;
node.getNodesStats( statistics.total = node.getNodesStats(
AF_UNSPEC, AF_UNSPEC,
&statistics.good, &statistics.good,
&statistics.dubious, &statistics.dubious,