diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 23957eaf5e..550e66de47 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -459,7 +459,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}; @@ -988,7 +988,7 @@ void PeerManager::FinalizeNode(const CNode& node) { { 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); } @@ -1045,7 +1045,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; } @@ -1199,16 +1199,16 @@ void PeerManager::Misbehaving(const NodeId pnode, const int howmuch, const std:: if (peer == nullptr) return; LOCK(peer->m_misbehavior_mutex); - peer->nMisbehavior += howmuch; + peer->m_misbehavior_score += howmuch; const int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD); const std::string message_prefixed = message.empty() ? "" : (": " + message); - if (peer->nMisbehavior >= banscore && peer->nMisbehavior - howmuch < banscore) + if (peer->m_misbehavior_score >= banscore && peer->m_misbehavior_score - howmuch < banscore) { - LogPrint(BCLog::NET, "Misbehaving: peer=%d (%d -> %d) DISCOURAGE THRESHOLD EXCEEDED%s\n", pnode, peer->nMisbehavior - howmuch, peer->nMisbehavior, message_prefixed); + 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; statsClient.inc("misbehavior.banned", 1.0f); } 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); statsClient.count("misbehavior.amount", howmuch, 1.0); } } diff --git a/src/net_processing.h b/src/net_processing.h index f6e8e18a34..53d259c601 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -137,7 +137,7 @@ private: }; struct CNodeStateStats { - int nMisbehavior = 0; + int m_misbehavior_score = 0; int nSyncHeight = -1; int nCommonHeight = -1; std::vector vHeightInFlight; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 6afafb8476..8118491014 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1264,7 +1264,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) // nodeStateStats couldn't be fetched. if (stats->fNodeStateStatsAvailable) { // Ban score is init to 0 - ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior)); + ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.m_misbehavior_score)); // Sync height is init to -1 if (stats->nodeStateStats.nSyncHeight > -1) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index c9e8ecafbb..55665cce79 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -206,7 +206,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request) obj.pushKV("masternode", stats.m_masternode_connection); obj.pushKV("startingheight", stats.nStartingHeight); if (fStateStats) { - obj.pushKV("banscore", statestats.nMisbehavior); + obj.pushKV("banscore", statestats.m_misbehavior_score); obj.pushKV("synced_headers", statestats.nSyncHeight); obj.pushKV("synced_blocks", statestats.nCommonHeight); UniValue heights(UniValue::VARR);