aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-cli.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-08-13 16:25:04 +0200
committerJon Atack <jon@atack.com>2020-08-31 16:11:59 +0200
commitd3f77b736e43b187771b901a6a3452f83c116918 (patch)
tree2b2b4b340798f9d01773589f2c46bad5dad96fac /src/bitcoin-cli.cpp
parent19377b2fd24704bff6c805946575b116f07d5e0d (diff)
cli: create inbound/outbound peer connections report
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r--src/bitcoin-cli.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index a2670ed1a6..7833aa946c 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -344,8 +344,8 @@ public:
if (!batch[ID_NETWORKINFO]["error"].isNull()) return batch[ID_NETWORKINFO];
// Count peer connection totals.
- int ipv4_i{0}, ipv6_i{0}, onion_i{0}, block_relay_i{0}; // inbound conn counters
- int ipv4_o{0}, ipv6_o{0}, onion_o{0}, block_relay_o{0}; // outbound conn counters
+ int ipv4_i{0}, ipv6_i{0}, onion_i{0}, block_relay_i{0}, total_i{0}; // inbound conn counters
+ int ipv4_o{0}, ipv6_o{0}, onion_o{0}, block_relay_o{0}, total_o{0}; // outbound conn counters
const UniValue& getpeerinfo{batch[ID_PEERINFO]["result"]};
for (const UniValue& peer : getpeerinfo.getValues()) {
@@ -379,6 +379,14 @@ public:
const UniValue& networkinfo{batch[ID_NETWORKINFO]["result"]};
std::string result{strprintf("%s %s%s - %i%s\n\n", PACKAGE_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].get_int(), networkinfo["subversion"].get_str())};
+ // Report peer connection totals by type.
+ total_i = ipv4_i + ipv6_i + onion_i;
+ total_o = ipv4_o + ipv6_o + onion_o;
+ result += " ipv4 ipv6 onion total block-relay\n";
+ result += strprintf("in %5i %5i %5i %5i %5i\n", ipv4_i, ipv6_i, onion_i, total_i, block_relay_i);
+ result += strprintf("out %5i %5i %5i %5i %5i\n", ipv4_o, ipv6_o, onion_o, total_o, block_relay_o);
+ result += strprintf("total %5i %5i %5i %5i %5i\n", ipv4_i + ipv4_o, ipv6_i + ipv6_o, onion_i + onion_o, total_i + total_o, block_relay_i + block_relay_o);
+
return JSONRPCReplyObj(UniValue{result}, NullUniValue, 1);
}
};