mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-07 19:48:58 +02:00
Merge bitcoin/bitcoin#26457: [24.x] backport rpc: skip getpeerinfo for a peer without CNodeStateStats
e72313e6b3fbf865e0eaa9aee0a555b7a7fe6850 rpc: Require NodeStateStats object in getpeerinfo (Martin Zumsande) Pull request description: Backports #26515. ACKs for top commit: fanquake: ACK e72313e6b3fbf865e0eaa9aee0a555b7a7fe6850 Tree-SHA512: 28e885ea299fe8a3a7538628d413c434bc42c251a2c1ae238bca0652709f5bd781eb157675171ab538f6e2f6f720f1c184200ac3857f6c78f48858949eed49da
This commit is contained in:
commit
2b87e90585
@ -185,6 +185,14 @@ static RPCHelpMan getpeerinfo()
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CNodeStateStats statestats;
|
||||
bool fStateStats = peerman.GetNodeStateStats(stats.nodeid, statestats);
|
||||
// GetNodeStateStats() requires the existence of a CNodeState and a Peer object
|
||||
// to succeed for this peer. These are created at connection initialisation and
|
||||
// exist for the duration of the connection - except if there is a race where the
|
||||
// peer got disconnected in between the GetNodeStats() and the GetNodeStateStats()
|
||||
// calls. In this case, the peer doesn't need to be reported here.
|
||||
if (!fStateStats) {
|
||||
continue;
|
||||
}
|
||||
obj.pushKV("id", stats.nodeid);
|
||||
obj.pushKV("addr", stats.m_addr_name);
|
||||
if (stats.addrBind.IsValid()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user