Skip to content

Commit 8e35bf5

Browse files
committed
scripted-diff: rename misbehavior members
-BEGIN VERIFY SCRIPT- sed -i 's/nMisbehavior/m_misbehavior_score/g' src/net_processing.cpp src/net_processing.h src/rpc/net.cpp src/qt/rpcconsole.cpp -END VERIFY SCRIPT-
1 parent 1f96d2e commit 8e35bf5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/net_processing.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ struct Peer {
482482
/** Protects misbehavior data members */
483483
Mutex m_misbehavior_mutex;
484484
/** Accumulated misbehavior score for this peer */
485-
int nMisbehavior GUARDED_BY(m_misbehavior_mutex){0};
485+
int m_misbehavior_score GUARDED_BY(m_misbehavior_mutex){0};
486486
/** Whether this peer should be disconnected and marked as discouraged (unless it has the noban permission). */
487487
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
488488

@@ -912,7 +912,7 @@ void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTim
912912
{
913913
PeerRef peer = GetPeerRef(nodeid);
914914
assert(peer != nullptr);
915-
misbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->nMisbehavior);
915+
misbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
916916
LOCK(g_peer_mutex);
917917
g_peer_map.erase(nodeid);
918918
}
@@ -967,7 +967,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
967967

968968
PeerRef peer = GetPeerRef(nodeid);
969969
if (peer == nullptr) return false;
970-
stats.nMisbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->nMisbehavior);
970+
stats.m_misbehavior_score = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
971971

972972
return true;
973973
}
@@ -1120,13 +1120,13 @@ void Misbehaving(const NodeId pnode, const int howmuch, const std::string& messa
11201120
if (peer == nullptr) return;
11211121

11221122
LOCK(peer->m_misbehavior_mutex);
1123-
peer->nMisbehavior += howmuch;
1123+
peer->m_misbehavior_score += howmuch;
11241124
const std::string message_prefixed = message.empty() ? "" : (": " + message);
1125-
if (peer->nMisbehavior >= DISCOURAGEMENT_THRESHOLD && peer->nMisbehavior - howmuch < DISCOURAGEMENT_THRESHOLD) {
1126-
LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d) DISCOURAGE THRESHOLD EXCEEDED%s\n", pnode, peer->nMisbehavior - howmuch, peer->nMisbehavior, message_prefixed);
1125+
if (peer->m_misbehavior_score >= DISCOURAGEMENT_THRESHOLD && peer->m_misbehavior_score - howmuch < DISCOURAGEMENT_THRESHOLD) {
1126+
LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d) DISCOURAGE THRESHOLD EXCEEDED%s\n", pnode, peer->m_misbehavior_score - howmuch, peer->m_misbehavior_score, message_prefixed);
11271127
peer->m_should_discourage = true;
11281128
} else {
1129-
LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d)%s\n", pnode, peer->nMisbehavior - howmuch, peer->nMisbehavior, message_prefixed);
1129+
LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d)%s\n", pnode, peer->m_misbehavior_score - howmuch, peer->m_misbehavior_score, message_prefixed);
11301130
}
11311131
}
11321132

src/net_processing.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class PeerLogicValidation final : public CValidationInterface, public NetEventsI
9090
};
9191

9292
struct CNodeStateStats {
93-
int nMisbehavior = 0;
93+
int m_misbehavior_score = 0;
9494
int nSyncHeight = -1;
9595
int nCommonHeight = -1;
9696
std::vector<int> vHeightInFlight;

src/rpc/net.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
193193
if (fStateStats) {
194194
if (IsDeprecatedRPCEnabled("banscore")) {
195195
// banscore is deprecated in v0.21 for removal in v0.22
196-
obj.pushKV("banscore", statestats.nMisbehavior);
196+
obj.pushKV("banscore", statestats.m_misbehavior_score);
197197
}
198198
obj.pushKV("synced_headers", statestats.nSyncHeight);
199199
obj.pushKV("synced_blocks", statestats.nCommonHeight);

0 commit comments

Comments
 (0)