aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2020-03-05 04:44:45 -0500
committerBen Woosley <ben.woosley@gmail.com>2020-03-05 04:44:50 -0500
commit1891245e7318bf625bbf67aab08a79fc3e87b61d (patch)
treed76e9593961fde8577fd909504f1cd61f54bd95c
parent7a810b1d7a9d03818706dc94457dc3255f062796 (diff)
downloadbitcoin-1891245e7318bf625bbf67aab08a79fc3e87b61d.tar.xz
refactor: Cast ping values to double before output
Note the divisor is a floating point literal so presumably also floating point.
-rw-r--r--src/rpc/net.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index e8ae458c57..97fe99b8c1 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -165,12 +165,15 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
obj.pushKV("bytesrecv", stats.nRecvBytes);
obj.pushKV("conntime", stats.nTimeConnected);
obj.pushKV("timeoffset", stats.nTimeOffset);
- if (stats.m_ping_usec > 0)
- obj.pushKV("pingtime", stats.m_ping_usec / 1e6);
- if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max())
- obj.pushKV("minping", stats.m_min_ping_usec / 1e6);
- if (stats.m_ping_wait_usec > 0)
- obj.pushKV("pingwait", stats.m_ping_wait_usec / 1e6);
+ if (stats.m_ping_usec > 0) {
+ obj.pushKV("pingtime", ((double)stats.m_ping_usec) / 1e6);
+ }
+ if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max()) {
+ obj.pushKV("minping", ((double)stats.m_min_ping_usec) / 1e6);
+ }
+ if (stats.m_ping_wait_usec > 0) {
+ obj.pushKV("pingwait", ((double)stats.m_ping_wait_usec) / 1e6);
+ }
obj.pushKV("version", stats.nVersion);
// Use the sanitized form of subver here, to avoid tricksy remote peers from
// corrupting or modifying the JSON output by putting special characters in