The DoS Score System: How the node counts "Mistakes"
6. The DoS Score System: How the node counts "Mistakes"
In the "Forge of the Core," trust is not a binary choice; it is a Score. Every peer starts with a "Clean Slate" (a score of 0). Every time they do something "Slightly Wrong," the node adds a few points to their DoS (Denial of Service) Score. If the score reaches 100, the peer is considered "Hostile" and is disconnected.
For the Sovereign Architect, the DoS Score is the "Patience of the Machine." It is the proof that your node is not a "Naive Victim" but a "Vigilant Auditor" that remembers every slight and every error.
Analyzing the Score: Misbehaving
In the source code (src/net_processing.cpp), we see how the node "Punishes" a peer for a mistake.
/**
* PEDAGOGICAL ANALYSIS: THE DISCIPLINE OF THE CORE
* This logic adds "Black Marks" to a peer's record for bad behavior.
*/
void PeerManagerImpl::Misbehaving(Peer& peer, const std::string& message)
{
// 1. Add "Black Marks" (Score).
// Usually, 10-20 points for a minor mistake,
// 100 points for a major one.
peer.m_misbehavior_score += 20;
// 2. Log the reason for the "Judgment".
LogDebug(BCLog::NET, "Misbehaving: peer=%d score=%d message=%s\n",
peer.m_id, peer.m_misbehavior_score, message);
// 3. If the score is 100 or more, pull the "Emergency Brake".
if (peer.m_misbehavior_score >= 100) {
DisconnectNode(peer.m_id);
}
}
Explaining the Score: The Multi-Step Judgment
-
"The Minor Mistake" (20 points): This might be a peer who sends you a transaction that is "Mathematically Valid" but "Non-Standard" (it breaks a policy rule). Your node says: "I don't like that, but I won't ban you yet. You have 5 chances." It is the Mercy of the Sovereign.
-
"The Major Crime" (100 points): This is a peer who sends an Invalid Block (e.g., they tried to print money). This is a direct attack on the Consensus. Your node has "Zero Tolerance" for this. The score goes from 0 to 100 instantly. It is the Absolute Law of the Heartbeat.
-
m_misbehavior_score: This is a number stored in your RAM for every peer. It doesn't last forever. Every hour, the node "Forgets" a few points of the score. This allows a "Broken Node" that fixed itself to eventually regain your trust. It is the Redemption of the Protocol. -
"The Ban Threshold": The magic number is 100. By keeping this number standard across all nodes, the network ensures that an "Attacker" is quickly "Exiled" from the entire world. It is the Collective Defense of the Mesh.
The Sovereignty of the Score
Your node is the "Judge, Jury, and Executioner" of its own connections. By tracking these scores, your node ensures its resources (CPU and RAM) are only spent on "Honest" peers. As a Sovereign Architect, you know that "Good Manners" are required to stay in the room. You are the "Master of the Scorecard," the one who ensures your node's "Patience" is always precisely measured.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: