From 362a5982130ba22a5a514383590fd066f962d968 Mon Sep 17 00:00:00 2001 From: furszy Date: Sat, 3 Apr 2021 11:58:29 -0300 Subject: [PATCH] Refactor: remove redundant `fAlreadyCheckedBlock` argument from `AcceptBlock` `CBlock` has a member `fChecked` that has the exact same purpose as the `fAlreadyCheckedBlock` flag. --- src/validation.cpp | 6 +++--- src/validation.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index f43ab0aa94cff..655785fec3b62 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3093,7 +3093,7 @@ bool AcceptBlockHeader(const CBlock& block, CValidationState& state, CBlockIndex return true; } -bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppindex, CDiskBlockPos* dbp, bool fAlreadyCheckedBlock) +bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppindex, CDiskBlockPos* dbp) { AssertLockHeld(cs_main); @@ -3126,7 +3126,7 @@ bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppi return true; } - if ((!fAlreadyCheckedBlock && !CheckBlock(block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) { + if (!CheckBlock(block, state) || !ContextualCheckBlock(block, state, pindex->pprev)) { if (state.IsInvalid() && !state.CorruptionPossible()) { pindex->nStatus |= BLOCK_FAILED_VALID; setDirtyBlockIndex.insert(pindex); @@ -3369,7 +3369,7 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const std::shared_pt // Store to disk CBlockIndex* pindex = nullptr; - bool ret = AcceptBlock(*pblock, state, &pindex, dbp, checked); + bool ret = AcceptBlock(*pblock, state, &pindex, dbp); if (fAccepted) *fAccepted = ret; CheckBlockIndex(); if (!ret) { diff --git a/src/validation.h b/src/validation.h index 12db5e777bde5..4ac0432d83615 100644 --- a/src/validation.h +++ b/src/validation.h @@ -337,7 +337,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn bool TestBlockValidity(CValidationState& state, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true, bool fCheckBlockSig = true); /** Store block on disk. If dbp is provided, the file is known to already reside on disk */ -bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** pindex, CDiskBlockPos* dbp = NULL, bool fAlreadyCheckedBlock = false); +bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** pindex, CDiskBlockPos* dbp = NULL); bool AcceptBlockHeader(const CBlock& block, CValidationState& state, CBlockIndex** ppindex = nullptr, CBlockIndex* pindexPrev = nullptr);