mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
net: rename misbehavior members using scripted-diff
implements 8e35bf59062b3a823182588e0bf809b3367c2be0 from https://github.com/bitcoin/bitcoin/pull/19607
This commit is contained in:
parent
60d589014c
commit
d0a35831db
@ -459,7 +459,7 @@ struct Peer {
|
|||||||
/** Protects misbehavior data members */
|
/** Protects misbehavior data members */
|
||||||
Mutex m_misbehavior_mutex;
|
Mutex m_misbehavior_mutex;
|
||||||
/** Accumulated misbehavior score for this peer */
|
/** 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). */
|
/** 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};
|
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
|
||||||
|
|
||||||
@ -988,7 +988,7 @@ void PeerManager::FinalizeNode(const CNode& node) {
|
|||||||
{
|
{
|
||||||
PeerRef peer = GetPeerRef(nodeid);
|
PeerRef peer = GetPeerRef(nodeid);
|
||||||
assert(peer != nullptr);
|
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);
|
LOCK(g_peer_mutex);
|
||||||
g_peer_map.erase(nodeid);
|
g_peer_map.erase(nodeid);
|
||||||
}
|
}
|
||||||
@ -1045,7 +1045,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
|
|||||||
|
|
||||||
PeerRef peer = GetPeerRef(nodeid);
|
PeerRef peer = GetPeerRef(nodeid);
|
||||||
if (peer == nullptr) return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1199,16 +1199,16 @@ void PeerManager::Misbehaving(const NodeId pnode, const int howmuch, const std::
|
|||||||
if (peer == nullptr) return;
|
if (peer == nullptr) return;
|
||||||
|
|
||||||
LOCK(peer->m_misbehavior_mutex);
|
LOCK(peer->m_misbehavior_mutex);
|
||||||
peer->nMisbehavior += howmuch;
|
peer->m_misbehavior_score += howmuch;
|
||||||
const int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
|
const int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
|
||||||
const std::string message_prefixed = message.empty() ? "" : (": " + message);
|
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;
|
peer->m_should_discourage = true;
|
||||||
statsClient.inc("misbehavior.banned", 1.0f);
|
statsClient.inc("misbehavior.banned", 1.0f);
|
||||||
} else {
|
} 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);
|
statsClient.count("misbehavior.amount", howmuch, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CNodeStateStats {
|
struct CNodeStateStats {
|
||||||
int nMisbehavior = 0;
|
int m_misbehavior_score = 0;
|
||||||
int nSyncHeight = -1;
|
int nSyncHeight = -1;
|
||||||
int nCommonHeight = -1;
|
int nCommonHeight = -1;
|
||||||
std::vector<int> vHeightInFlight;
|
std::vector<int> vHeightInFlight;
|
||||||
|
@ -1264,7 +1264,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
|
|||||||
// nodeStateStats couldn't be fetched.
|
// nodeStateStats couldn't be fetched.
|
||||||
if (stats->fNodeStateStatsAvailable) {
|
if (stats->fNodeStateStatsAvailable) {
|
||||||
// Ban score is init to 0
|
// 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
|
// Sync height is init to -1
|
||||||
if (stats->nodeStateStats.nSyncHeight > -1)
|
if (stats->nodeStateStats.nSyncHeight > -1)
|
||||||
|
@ -206,7 +206,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||||||
obj.pushKV("masternode", stats.m_masternode_connection);
|
obj.pushKV("masternode", stats.m_masternode_connection);
|
||||||
obj.pushKV("startingheight", stats.nStartingHeight);
|
obj.pushKV("startingheight", stats.nStartingHeight);
|
||||||
if (fStateStats) {
|
if (fStateStats) {
|
||||||
obj.pushKV("banscore", statestats.nMisbehavior);
|
obj.pushKV("banscore", statestats.m_misbehavior_score);
|
||||||
obj.pushKV("synced_headers", statestats.nSyncHeight);
|
obj.pushKV("synced_headers", statestats.nSyncHeight);
|
||||||
obj.pushKV("synced_blocks", statestats.nCommonHeight);
|
obj.pushKV("synced_blocks", statestats.nCommonHeight);
|
||||||
UniValue heights(UniValue::VARR);
|
UniValue heights(UniValue::VARR);
|
||||||
|
Loading…
Reference in New Issue
Block a user