Move LoadBlockIndexDB to BlockManager

pull/22371/head
MarcoFalke 3 years ago
parent c0224bc962
commit fa27f03b49
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -3764,10 +3764,10 @@ void BlockManager::Unload() {
m_block_index.clear(); m_block_index.clear();
} }
bool CChainState::LoadBlockIndexDB() bool BlockManager::LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates)
{ {
if (!m_blockman.LoadBlockIndex( if (!LoadBlockIndex(
m_params.GetConsensus(), *pblocktree, ::Params().GetConsensus(), *pblocktree,
setBlockIndexCandidates)) { setBlockIndexCandidates)) {
return false; return false;
} }
@ -3792,7 +3792,7 @@ bool CChainState::LoadBlockIndexDB()
// Check presence of blk files // Check presence of blk files
LogPrintf("Checking all blk files are present...\n"); LogPrintf("Checking all blk files are present...\n");
std::set<int> setBlkDataFiles; std::set<int> setBlkDataFiles;
for (const std::pair<const uint256, CBlockIndex*>& item : m_blockman.m_block_index) { for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index) {
CBlockIndex* pindex = item.second; CBlockIndex* pindex = item.second;
if (pindex->nStatus & BLOCK_HAVE_DATA) { if (pindex->nStatus & BLOCK_HAVE_DATA) {
setBlkDataFiles.insert(pindex->nFile); setBlkDataFiles.insert(pindex->nFile);
@ -4114,7 +4114,7 @@ bool ChainstateManager::LoadBlockIndex()
// Load block index from databases // Load block index from databases
bool needs_init = fReindex; bool needs_init = fReindex;
if (!fReindex) { if (!fReindex) {
bool ret = ActiveChainstate().LoadBlockIndexDB(); bool ret = m_blockman.LoadBlockIndexDB(ActiveChainstate().setBlockIndexCandidates);
if (!ret) return false; if (!ret) return false;
needs_init = m_blockman.m_block_index.empty(); needs_init = m_blockman.m_block_index.empty();
} }

@ -446,6 +446,8 @@ public:
*/ */
std::multimap<CBlockIndex*, CBlockIndex*> m_blocks_unlinked; std::multimap<CBlockIndex*, CBlockIndex*> m_blocks_unlinked;
bool LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
/** /**
* Load the blocktree off disk and into memory. Populate certain metadata * Load the blocktree off disk and into memory. Populate certain metadata
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral * per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
@ -798,8 +800,6 @@ private:
void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main); void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main); void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
//! Indirection necessary to make lock annotations work with an optional mempool. //! Indirection necessary to make lock annotations work with an optional mempool.
RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs) RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
{ {

Loading…
Cancel
Save