Merge 29530 via rpc_getpeerinfo_misbehaving_score-26

This commit is contained in:
Luke Dashjr 2024-03-25 17:26:53 +00:00
commit c8767e17f1
4 changed files with 6 additions and 0 deletions

View File

@ -1730,6 +1730,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c
stats.presync_height = peer->m_headers_sync->GetPresyncHeight();
}
}
stats.m_misbehavior_score = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
return true;
}

View File

@ -41,6 +41,7 @@ struct CNodeStateStats {
bool m_addr_relay_enabled{false};
ServiceFlags their_services;
int64_t presync_height{-1};
int m_misbehavior_score{0};
};
class PeerManager : public CValidationInterface, public NetEventsInterface

View File

@ -174,6 +174,8 @@ static RPCHelpMan getpeerinfo()
"best capture connection behaviors."},
{RPCResult::Type::STR, "transport_protocol_type", "Type of transport protocol: \n" + Join(TRANSPORT_TYPE_DOC, ",\n") + ".\n"},
{RPCResult::Type::STR, "session_id", "The session ID for this connection, or \"\" if there is none (\"v2\" transport protocol only).\n"},
{RPCResult::Type::NUM, "misbehavior_score", "The accumulated misbehavior score for this peer.\n"
"The peer will be disconnected if 100 is reached.\n"},
}},
}},
},
@ -281,6 +283,7 @@ static RPCHelpMan getpeerinfo()
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
obj.pushKV("transport_protocol_type", TransportTypeAsString(stats.m_transport_type));
obj.pushKV("session_id", stats.m_session_id);
obj.pushKV("misbehavior_score", statestats.m_misbehavior_score);
ret.push_back(obj);
}

View File

@ -153,6 +153,7 @@ class NetTest(BitcoinTestFramework):
"timeoffset": 0,
"transport_protocol_type": "v1" if not self.options.v2transport else "detecting",
"version": 0,
"misbehavior_score": 0,
},
)
no_version_peer.peer_disconnect()