aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-06-16 16:27:34 -0400
committerJohn Newbery <john@johnnewbery.com>2020-08-12 11:23:22 +0100
commit8e35bf59062b3a823182588e0bf809b3367c2be0 (patch)
tree07137095012ce1b833c1c5d468188d4a5c48ebb7 /src
parent1f96d2e673a78220eebf3bbd15b121c51c4cd97b (diff)
downloadbitcoin-8e35bf59062b3a823182588e0bf809b3367c2be0.tar.xz
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-
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp14
-rw-r--r--src/net_processing.h2
-rw-r--r--src/rpc/net.cpp2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 2edd57f458..07562679f7 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -482,7 +482,7 @@ struct Peer {
/** Protects misbehavior data members */
Mutex m_misbehavior_mutex;
/** Accumulated misbehavior score for this peer */
- int nMisbehavior GUARDED_BY(m_misbehavior_mutex){0};
+ int m_misbehavior_score GUARDED_BY(m_misbehavior_mutex){0};
/** Whether this peer should be disconnected and marked as discouraged (unless it has the noban permission). */
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
@@ -912,7 +912,7 @@ void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTim
{
PeerRef peer = GetPeerRef(nodeid);
assert(peer != nullptr);
- misbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->nMisbehavior);
+ misbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
LOCK(g_peer_mutex);
g_peer_map.erase(nodeid);
}
@@ -967,7 +967,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
PeerRef peer = GetPeerRef(nodeid);
if (peer == nullptr) return false;
- stats.nMisbehavior = WITH_LOCK(peer->m_misbehavior_mutex, return peer->nMisbehavior);
+ stats.m_misbehavior_score = WITH_LOCK(peer->m_misbehavior_mutex, return peer->m_misbehavior_score);
return true;
}
@@ -1120,13 +1120,13 @@ void Misbehaving(const NodeId pnode, const int howmuch, const std::string& messa
if (peer == nullptr) return;
LOCK(peer->m_misbehavior_mutex);
- peer->nMisbehavior += howmuch;
+ peer->m_misbehavior_score += howmuch;
const std::string message_prefixed = message.empty() ? "" : (": " + message);
- if (peer->nMisbehavior >= DISCOURAGEMENT_THRESHOLD && peer->nMisbehavior - howmuch < DISCOURAGEMENT_THRESHOLD) {
- LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d) DISCOURAGE THRESHOLD EXCEEDED%s\n", pnode, peer->nMisbehavior - howmuch, peer->nMisbehavior, message_prefixed);
+ if (peer->m_misbehavior_score >= DISCOURAGEMENT_THRESHOLD && peer->m_misbehavior_score - howmuch < DISCOURAGEMENT_THRESHOLD) {
+ 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);
peer->m_should_discourage = true;
} else {
- LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d)%s\n", pnode, peer->nMisbehavior - howmuch, peer->nMisbehavior, message_prefixed);
+ LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d)%s\n", pnode, peer->m_misbehavior_score - howmuch, peer->m_misbehavior_score, message_prefixed);
}
}
diff --git a/src/net_processing.h b/src/net_processing.h
index 2d98714122..355f539354 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -90,7 +90,7 @@ private:
};
struct CNodeStateStats {
- int nMisbehavior = 0;
+ int m_misbehavior_score = 0;
int nSyncHeight = -1;
int nCommonHeight = -1;
std::vector<int> vHeightInFlight;
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 09265bc480..653baa9530 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -193,7 +193,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
if (fStateStats) {
if (IsDeprecatedRPCEnabled("banscore")) {
// banscore is deprecated in v0.21 for removal in v0.22
- obj.pushKV("banscore", statestats.nMisbehavior);
+ obj.pushKV("banscore", statestats.m_misbehavior_score);
}
obj.pushKV("synced_headers", statestats.nSyncHeight);
obj.pushKV("synced_blocks", statestats.nCommonHeight);