0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

refactor: Cast ping values to double before output

Note the divisor is a floating point literal so presumably
also floating point.
This commit is contained in:
Ben Woosley 2020-03-05 04:44:45 -05:00
parent 7a810b1d7a
commit 1891245e73
No known key found for this signature in database
GPG key ID: 6EE5F3785F78B345

View file

@ -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