aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-10-25 15:11:41 +0100
committerJon Atack <jon@atack.com>2020-10-25 16:51:21 +0100
commit398045ba8b3694931069f88ec95553b3207dd1a6 (patch)
tree06f1968a8417fd37070443145f71aa97f17260c6 /src
parent773f4c99c00c0b1d8c1b53cb99ba571337100953 (diff)
cli -netinfo: print oversized/extreme ping times as "-"
Diffstat (limited to 'src')
-rw-r--r--src/bitcoin-cli.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 8e17319425..ef4641cb63 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -343,6 +343,12 @@ private:
if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
return "";
}
+ std::string PingTimeToString(double seconds) const
+ {
+ if (seconds < 0) return "";
+ const double milliseconds{round(1000 * seconds)};
+ return milliseconds > 999999 ? "-" : ToString(milliseconds);
+ }
const int64_t m_time_now{GetSystemTimeInSeconds()};
public:
@@ -428,8 +434,8 @@ public:
peer.is_outbound ? "out" : "in",
peer.is_block_relay ? "block" : "full",
peer.network,
- peer.min_ping == -1 ? "" : ToString(round(1000 * peer.min_ping)),
- peer.ping == -1 ? "" : ToString(round(1000 * peer.ping)),
+ PingTimeToString(peer.min_ping),
+ PingTimeToString(peer.ping),
peer.last_send == 0 ? "" : ToString(m_time_now - peer.last_send),
peer.last_recv == 0 ? "" : ToString(m_time_now - peer.last_recv),
peer.last_trxn == 0 ? "" : ToString((m_time_now - peer.last_trxn) / 60),