Skip to content

Commit 66b8c66

Browse files
committed
Merge 29530 via rpc_getpeerinfo_misbehaving_score-28
2 parents d50d30b + d3e4394 commit 66b8c66

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c
19331933
}
19341934
}
19351935
stats.time_offset = peer->m_time_offset;
1936+
stats.m_misbehavior_score = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_should_discourage) ? 100 : 0;
19361937

19371938
return true;
19381939
}

src/net_processing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct CNodeStateStats {
4747
ServiceFlags their_services;
4848
int64_t presync_height{-1};
4949
std::chrono::seconds time_offset{0};
50+
int m_misbehavior_score{0};
5051
};
5152

5253
struct PeerManagerInfo {

src/rpc/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static RPCHelpMan getpeerinfo()
213213
"best capture connection behaviors."},
214214
{RPCResult::Type::STR, "transport_protocol_type", "Type of transport protocol: \n" + Join(TRANSPORT_TYPE_DOC, ",\n") + ".\n"},
215215
{RPCResult::Type::STR, "session_id", "The session ID for this connection, or \"\" if there is none (\"v2\" transport protocol only).\n"},
216+
{RPCResult::Type::NUM, "misbehavior_score", "The misbehavior score for this peer. Always 0, but may be 100 if the peer is about to be disconnected. (DEPRECATED)\n"},
216217
}},
217218
}},
218219
},
@@ -325,6 +326,7 @@ static RPCHelpMan getpeerinfo()
325326
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
326327
obj.pushKV("transport_protocol_type", TransportTypeAsString(stats.m_transport_type));
327328
obj.pushKV("session_id", stats.m_session_id);
329+
obj.pushKV("misbehavior_score", statestats.m_misbehavior_score);
328330

329331
ret.push_back(std::move(obj));
330332
}

test/functional/rpc_net.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def test_getpeerinfo(self):
178178
"timeoffset": 0,
179179
"transport_protocol_type": "v1" if not self.options.v2transport else "v2",
180180
"version": 0,
181+
"misbehavior_score": 0,
181182
},
182183
)
183184
no_version_peer.peer_disconnect()

0 commit comments

Comments
 (0)