diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 4c3aacaf5..92b7a75f7 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1262,8 +1262,8 @@ bool static ProcessHeadersMessage(CNode *pfrom, CConnman *connman, const std::ve if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast, &first_invalid_header)) { int nDoS; if (state.IsInvalid(nDoS)) { + LOCK(cs_main); if (nDoS > 0) { - LOCK(cs_main); Misbehaving(pfrom->GetId(), nDoS); } if (punish_duplicate_invalid && mapBlockIndex.find(first_invalid_header.GetHash()) != mapBlockIndex.end()) {