[net processing] Move ping data fields to net processing

This commit is contained in:
John Newbery
2020-06-21 18:56:19 -04:00
parent dd2646d12c
commit 45dcf22661
6 changed files with 66 additions and 51 deletions

View File

@@ -77,13 +77,12 @@ static RPCHelpMan ping()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
NodeContext& node = EnsureNodeContext(request.context);
if(!node.connman)
if (!node.peerman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}
// Request that each node send a ping during next message processing pass
node.connman->ForEachNode([](CNode* pnode) {
pnode->fPingQueued = true;
});
node.peerman->SendPings();
return NullUniValue;
},
};
@@ -209,8 +208,8 @@ static RPCHelpMan getpeerinfo()
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);
if (fStateStats && statestats.m_ping_wait_usec > 0) {
obj.pushKV("pingwait", ((double)statestats.m_ping_wait_usec) / 1e6);
}
obj.pushKV("version", stats.nVersion);
// Use the sanitized form of subver here, to avoid tricksy remote peers from