New interfaces for statistics.

This commit is contained in:
Nicolás Ortega Froysa 2017-11-08 02:25:15 +01:00
parent 747bc4d328
commit d513080baa
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
2 changed files with 27 additions and 2 deletions

View File

@ -112,6 +112,13 @@ int NeoComm_export_nodes(const char *node_file);
*/ */
const char *NeoComm_get_node_stats(); const char *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,6 +113,24 @@ int NeoComm_export_nodes(const char *node_file) {
return 1; return 1;
} }
const char *NeoComm_get_node_stats() { unsigned int NeoComm_count_connected_nodes() {
return node.getNodesStats(AF_UNSPEC).toString().c_str(); return node.getNodesStats(AF_UNSPEC).getKnownNodes();
}
const char *NeoComm_get_node_stats() {
unsigned int good, dubious, cached, incoming, total;
total = node.getNodesStats(
AF_UNSPEC,
&good,
&dubious,
&cached,
&incoming);
std::string stats;
stats += "Good: " + good + std::string("\n");
stats += "Dubious: " + dubious + std::string("\n");
stats += "Cached: " + cached + std::string("\n");
stats += "Incoming: " + incoming + std::string("\n");
stats += "Total: " + total + std::string("\n");
return stats.c_str();
} }