From 34477ccd39a8d4bfa8ad612f22d5a46291922185 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 16 Jan 2019 13:11:13 +1000 Subject: [refactor] Add useful-for-dos "reason" field to CValidationState This is a first step towards cleaning up our DoS interface - make validation return *why* something is invalid, and let net_processing figure out what that implies in terms of banning/disconnection/etc. Behavior change: peers will now be banned for providing blocks with premature coinbase spends. Co-authored-by: Anthony Towns Suhas Daftuar --- src/net_processing.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/net_processing.cpp') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a416093db1..489ffcdc66 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -961,6 +961,7 @@ void Misbehaving(NodeId pnode, int howmuch, const std::string& message) EXCLUSIV static bool TxRelayMayResultInDisconnect(const CValidationState& state) { + assert(state.GetDoS() == state.GetDoSForReason()); return (state.GetDoS() > 0); } @@ -975,6 +976,7 @@ static bool TxRelayMayResultInDisconnect(const CValidationState& state) * txs, the peer should not be punished. See BIP 152. */ static bool MaybePunishNode(NodeId nodeid, const CValidationState& state, bool via_compact_block, const std::string& message = "") { + assert(state.GetDoS() == state.GetDoSForReason()); int nDoS = state.GetDoS(); if (nDoS > 0 && !via_compact_block) { LOCK(cs_main); -- cgit v1.2.3