From 5a807736dacfc3e6fa57231219336acf08be38fb Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Wed, 21 Jul 2021 14:13:33 -0400 Subject: [PATCH] validation: insert assumed-valid block index entries into candidates --- src/validation.cpp | 4 +++- src/validation.h | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index d34f4d636c..fc498f6e9b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3773,7 +3773,9 @@ bool BlockManager::LoadBlockIndex( pindex->nStatus |= BLOCK_FAILED_CHILD; setDirtyBlockIndex.insert(pindex); } - if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && (pindex->HaveTxsDownloaded() || pindex->pprev == nullptr)) { + if (pindex->IsAssumedValid() || + (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && + (pindex->HaveTxsDownloaded() || pindex->pprev == nullptr))) { block_index_candidates.insert(pindex); } if (pindex->nStatus & BLOCK_FAILED_MASK && (!pindexBestInvalid || pindex->nChainWork > pindexBestInvalid->nChainWork)) diff --git a/src/validation.h b/src/validation.h index d457f1ac65..fb12f65144 100644 --- a/src/validation.h +++ b/src/validation.h @@ -647,9 +647,10 @@ public: const std::optional m_from_snapshot_blockhash; /** - * The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and - * as good as our current tip or better. Entries may be failed, though, and pruning nodes may be - * missing the data for the block. + * The set of all CBlockIndex entries with either BLOCK_VALID_TRANSACTIONS (for + * itself and all ancestors) *or* BLOCK_ASSUMED_VALID (if using background + * chainstates) and as good as our current tip or better. Entries may be failed, + * though, and pruning nodes may be missing the data for the block. */ std::set setBlockIndexCandidates;