Skip to content

Commit 1891245

Browse files
committed
refactor: Cast ping values to double before output
Note the divisor is a floating point literal so presumably also floating point.
1 parent 7a810b1 commit 1891245

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/rpc/net.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,15 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
165165
obj.pushKV("bytesrecv", stats.nRecvBytes);
166166
obj.pushKV("conntime", stats.nTimeConnected);
167167
obj.pushKV("timeoffset", stats.nTimeOffset);
168-
if (stats.m_ping_usec > 0)
169-
obj.pushKV("pingtime", stats.m_ping_usec / 1e6);
170-
if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max())
171-
obj.pushKV("minping", stats.m_min_ping_usec / 1e6);
172-
if (stats.m_ping_wait_usec > 0)
173-
obj.pushKV("pingwait", stats.m_ping_wait_usec / 1e6);
168+
if (stats.m_ping_usec > 0) {
169+
obj.pushKV("pingtime", ((double)stats.m_ping_usec) / 1e6);
170+
}
171+
if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max()) {
172+
obj.pushKV("minping", ((double)stats.m_min_ping_usec) / 1e6);
173+
}
174+
if (stats.m_ping_wait_usec > 0) {
175+
obj.pushKV("pingwait", ((double)stats.m_ping_wait_usec) / 1e6);
176+
}
174177
obj.pushKV("version", stats.nVersion);
175178
// Use the sanitized form of subver here, to avoid tricksy remote peers from
176179
// corrupting or modifying the JSON output by putting special characters in

0 commit comments

Comments
 (0)