Skip to content

Commit

Permalink
Refactor: remove redundant fAlreadyCheckedBlock argument from `Acce…
Browse files Browse the repository at this point in the history
…ptBlock`

`CBlock` has a member `fChecked` that has the exact same purpose as the `fAlreadyCheckedBlock` flag.
  • Loading branch information
furszy committed Apr 7, 2021
1 parent 47cae28 commit 362a598
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down

0 comments on commit 362a598

Please sign in to comment.