Skip to content

Commit 40f5cb8

Browse files
committed
Send rejects and apply DoS scoring for errors in direct block validation.
75f51f2 introduced asynchronous processing for blocks, where reject messages and DoS scoring could be applied outside of ProcessBlock, because block validation may happen later. However, some types of errors are still detected immediately (in particular, CheckBlock violations), which need acting after ProcessBlock returns.
1 parent e81e2e8 commit 40f5cb8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3984,6 +3984,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
39843984

39853985
CValidationState state;
39863986
ProcessBlock(state, pfrom, &block);
3987+
int nDoS;
3988+
if (state.IsInvalid(nDoS)) {
3989+
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),
3990+
state.GetRejectReason(), inv.hash);
3991+
if (nDoS > 0) {
3992+
LOCK(cs_main);
3993+
Misbehaving(pfrom->GetId(), nDoS);
3994+
}
3995+
}
3996+
39873997
}
39883998

39893999

0 commit comments

Comments
 (0)