Skip to content

Commit

Permalink
Move LoadBlockIndexDB to BlockManager
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Jul 15, 2021
1 parent c0224bc commit fa27f03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3764,10 +3764,10 @@ void BlockManager::Unload() {
m_block_index.clear();
}

bool CChainState::LoadBlockIndexDB()
bool BlockManager::LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates)
{
if (!m_blockman.LoadBlockIndex(
m_params.GetConsensus(), *pblocktree,
if (!LoadBlockIndex(
::Params().GetConsensus(), *pblocktree,
setBlockIndexCandidates)) {
return false;
}
Expand All @@ -3792,7 +3792,7 @@ bool CChainState::LoadBlockIndexDB()
// Check presence of blk files
LogPrintf("Checking all blk files are present...\n");
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;
if (pindex->nStatus & BLOCK_HAVE_DATA) {
setBlkDataFiles.insert(pindex->nFile);
Expand Down Expand Up @@ -4114,7 +4114,7 @@ bool ChainstateManager::LoadBlockIndex()
// Load block index from databases
bool needs_init = fReindex;
if (!fReindex) {
bool ret = ActiveChainstate().LoadBlockIndexDB();
bool ret = m_blockman.LoadBlockIndexDB(ActiveChainstate().setBlockIndexCandidates);
if (!ret) return false;
needs_init = m_blockman.m_block_index.empty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ class BlockManager
*/
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
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
Expand Down Expand Up @@ -798,8 +800,6 @@ class CChainState
void CheckForkWarningConditions() 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.
RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
{
Expand Down

0 comments on commit fa27f03

Please sign in to comment.