diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -729,8 +729,18 @@ */ std::multimap m_blocks_unlinked; + /** + * Load the blocktree off disk and into memory. Populate certain metadata + * per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as + * peripheral collections like setDirtyBlockIndex. + * + * @param[out] block_index_candidates Fill this set with any valid blocks + * for which we've downloaded all transactions. + */ bool LoadBlockIndex(const Consensus::Params &consensus_params, - CBlockTreeDB &blocktree) + CBlockTreeDB &blocktree, + std::set + &block_index_candidates) EXCLUSIVE_LOCKS_REQUIRED(cs_main); /** Clear all data members. */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4497,8 +4497,10 @@ return pindexNew; } -bool BlockManager::LoadBlockIndex(const Consensus::Params ¶ms, - CBlockTreeDB &blocktree) { +bool BlockManager::LoadBlockIndex( + const Consensus::Params ¶ms, CBlockTreeDB &blocktree, + std::set + &block_index_candidates) { AssertLockHeld(cs_main); if (!blocktree.LoadBlockIndexGuts( params, [this](const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED( @@ -4541,7 +4543,7 @@ } if (pindex->IsValid(BlockValidity::TRANSACTIONS) && (pindex->HaveTxsDownloaded() || pindex->pprev == nullptr)) { - ::ChainstateActive().setBlockIndexCandidates.insert(pindex); + block_index_candidates.insert(pindex); } if (pindex->nStatus.isInvalid() && @@ -4583,7 +4585,9 @@ static bool LoadBlockIndexDB(const Consensus::Params ¶ms) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - if (!g_blockman.LoadBlockIndex(params, *pblocktree)) { + if (!g_blockman.LoadBlockIndex( + params, *pblocktree, + ::ChainstateActive().setBlockIndexCandidates)) { return false; }