diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:32:01 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:32:01 +0200 |
commit | 1ed6441925f424b9b2b280f1fa498f3d22dbb890 (patch) | |
tree | 5305e4c1260c1e1cf89bc48bc7e3575eb8130b94 /src/rpc/core_rpc_server.cpp | |
parent | Merge pull request #5326 (diff) | |
parent | New interactive daemon command 'print_net_stats': Global traffic stats (diff) | |
download | monero-1ed6441925f424b9b2b280f1fa498f3d22dbb890.tar.xz |
Merge pull request #5327
c23ea796 New interactive daemon command 'print_net_stats': Global traffic stats (rbrunner7)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 7af62bfe0..f5f1a2f9a 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -268,6 +268,23 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_get_net_stats(const COMMAND_RPC_GET_NET_STATS::request& req, COMMAND_RPC_GET_NET_STATS::response& res, const connection_context *ctx) + { + PERF_TIMER(on_get_net_stats); + // No bootstrap daemon check: Only ever get stats about local server + res.start_time = (uint64_t)m_core.get_start_time(); + { + CRITICAL_REGION_LOCAL(epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_in); + epee::net_utils::network_throttle_manager::get_global_throttle_in().get_stats(res.total_packets_in, res.total_bytes_in); + } + { + CRITICAL_REGION_LOCAL(epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_out); + epee::net_utils::network_throttle_manager::get_global_throttle_out().get_stats(res.total_packets_out, res.total_bytes_out); + } + res.status = CORE_RPC_STATUS_OK; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ class pruned_transaction { transaction& tx; public: |