Skip to content

Commit

Permalink
Eliminate unnecessary call to CheckBlock (#1498)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
OlegGirko authored and UdjinM6 committed Jul 1, 2017
1 parent 029ee64 commit a124914
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a124914

Please sign in to comment.