mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
[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 <aj@erisian.com.au> Suhas Daftuar <sdaftuar@gmail.com>
This commit is contained in:
committed by
Suhas Daftuar
parent
6a7f8777a0
commit
34477ccd39
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user