refactoring: add block_index_candidates arg to LoadBlockIndex

Prevents BlockManager from having to reference ChainstateActive()
within one of its methods which improves encapsulation and makes
testing easier.
This commit is contained in:
James O'Beirne
2019-06-24 15:22:33 -04:00
parent 613c46fe9e
commit 4ed55dfcd7
2 changed files with 20 additions and 5 deletions

View File

@@ -475,9 +475,19 @@ public:
*/
std::multimap<CBlockIndex*, CBlockIndex*> 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) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
CBlockTreeDB& blocktree,
std::set<CBlockIndex*, CBlockIndexWorkComparator>& block_index_candidates)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Clear all data members. */
void Unload() EXCLUSIVE_LOCKS_REQUIRED(cs_main);