From a12491448db6c492fc52c097a8006aae01f8f9c9 Mon Sep 17 00:00:00 2001 From: Oleg Girko Date: Sat, 1 Jul 2017 19:57:28 +0100 Subject: [PATCH] Eliminate unnecessary call to CheckBlock (#1498) ProcessNewBlock would return failure early if CheckBlock failed, before calling AcceptBlock. AcceptBlock also calls CheckBlock, and upon failure would update mapBlockIndex to indicate that a block was failed. By returning early in ProcessNewBlock, we were not marking blocks that fail a check in CheckBlock as permanently failed, and thus would continue to re-request and reprocess them. --- src/main.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4fcb7001b..dd947b0be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4013,16 +4013,10 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos* dbp) { - // Preliminary checks - bool checked = CheckBlock(*pblock, state); - { LOCK(cs_main); bool fRequested = MarkBlockAsReceived(pblock->GetHash()); fRequested |= fForceProcessing; - if (!checked) { - return error("%s: CheckBlock FAILED", __func__); - } // Store to disk CBlockIndex *pindex = NULL;