Merge pull request #2753

fa514082 RPC: get_info add rpc_connections_count (Tim L)
This commit is contained in:
Riccardo Spagni 2017-11-14 15:54:33 +02:00
commit a2241e8151
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
4 changed files with 15 additions and 0 deletions

View File

@ -213,6 +213,12 @@ namespace net_utils
int get_binded_port(){return m_port;} int get_binded_port(){return m_port;}
long get_connections_count() const
{
auto connections_count = (m_sock_count > 0) ? (m_sock_count - 1) : 0; // Socket count minus listening socket
return connections_count;
}
boost::asio::io_service& get_io_service(){return io_service_;} boost::asio::io_service& get_io_service(){return io_service_;}
struct idle_callback_conext_base struct idle_callback_conext_base

View File

@ -117,6 +117,11 @@ namespace epee
return m_net_server.get_binded_port(); return m_net_server.get_binded_port();
} }
long get_connections_count() const
{
return m_net_server.get_connections_count();
}
protected: protected:
net_utils::boosted_tcp_server<net_utils::http::http_custom_handler<t_connection_context> > m_net_server; net_utils::boosted_tcp_server<net_utils::http::http_custom_handler<t_connection_context> > m_net_server;
}; };

View File

@ -153,6 +153,7 @@ namespace cryptonote
uint64_t total_conn = m_p2p.get_connections_count(); uint64_t total_conn = m_p2p.get_connections_count();
res.outgoing_connections_count = m_p2p.get_outgoing_connections_count(); res.outgoing_connections_count = m_p2p.get_outgoing_connections_count();
res.incoming_connections_count = total_conn - res.outgoing_connections_count; res.incoming_connections_count = total_conn - res.outgoing_connections_count;
res.rpc_connections_count = get_connections_count();
res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count(); res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count();
res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count(); res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count();
res.testnet = m_testnet; res.testnet = m_testnet;
@ -1395,6 +1396,7 @@ namespace cryptonote
uint64_t total_conn = m_p2p.get_connections_count(); uint64_t total_conn = m_p2p.get_connections_count();
res.outgoing_connections_count = m_p2p.get_outgoing_connections_count(); res.outgoing_connections_count = m_p2p.get_outgoing_connections_count();
res.incoming_connections_count = total_conn - res.outgoing_connections_count; res.incoming_connections_count = total_conn - res.outgoing_connections_count;
res.rpc_connections_count = get_connections_count();
res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count(); res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count();
res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count(); res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count();
res.testnet = m_testnet; res.testnet = m_testnet;

View File

@ -919,6 +919,7 @@ namespace cryptonote
uint64_t alt_blocks_count; uint64_t alt_blocks_count;
uint64_t outgoing_connections_count; uint64_t outgoing_connections_count;
uint64_t incoming_connections_count; uint64_t incoming_connections_count;
uint64_t rpc_connections_count;
uint64_t white_peerlist_size; uint64_t white_peerlist_size;
uint64_t grey_peerlist_size; uint64_t grey_peerlist_size;
bool testnet; bool testnet;
@ -938,6 +939,7 @@ namespace cryptonote
KV_SERIALIZE(alt_blocks_count) KV_SERIALIZE(alt_blocks_count)
KV_SERIALIZE(outgoing_connections_count) KV_SERIALIZE(outgoing_connections_count)
KV_SERIALIZE(incoming_connections_count) KV_SERIALIZE(incoming_connections_count)
KV_SERIALIZE(rpc_connections_count)
KV_SERIALIZE(white_peerlist_size) KV_SERIALIZE(white_peerlist_size)
KV_SERIALIZE(grey_peerlist_size) KV_SERIALIZE(grey_peerlist_size)
KV_SERIALIZE(testnet) KV_SERIALIZE(testnet)