Skip to content

Commit fa27f03

Browse files
author
MarcoFalke
committed
Move LoadBlockIndexDB to BlockManager
1 parent c0224bc commit fa27f03

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,10 +3764,10 @@ void BlockManager::Unload() {
37643764
m_block_index.clear();
37653765
}
37663766

3767-
bool CChainState::LoadBlockIndexDB()
3767+
bool BlockManager::LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates)
37683768
{
3769-
if (!m_blockman.LoadBlockIndex(
3770-
m_params.GetConsensus(), *pblocktree,
3769+
if (!LoadBlockIndex(
3770+
::Params().GetConsensus(), *pblocktree,
37713771
setBlockIndexCandidates)) {
37723772
return false;
37733773
}
@@ -3792,7 +3792,7 @@ bool CChainState::LoadBlockIndexDB()
37923792
// Check presence of blk files
37933793
LogPrintf("Checking all blk files are present...\n");
37943794
std::set<int> setBlkDataFiles;
3795-
for (const std::pair<const uint256, CBlockIndex*>& item : m_blockman.m_block_index) {
3795+
for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index) {
37963796
CBlockIndex* pindex = item.second;
37973797
if (pindex->nStatus & BLOCK_HAVE_DATA) {
37983798
setBlkDataFiles.insert(pindex->nFile);
@@ -4114,7 +4114,7 @@ bool ChainstateManager::LoadBlockIndex()
41144114
// Load block index from databases
41154115
bool needs_init = fReindex;
41164116
if (!fReindex) {
4117-
bool ret = ActiveChainstate().LoadBlockIndexDB();
4117+
bool ret = m_blockman.LoadBlockIndexDB(ActiveChainstate().setBlockIndexCandidates);
41184118
if (!ret) return false;
41194119
needs_init = m_blockman.m_block_index.empty();
41204120
}

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ class BlockManager
446446
*/
447447
std::multimap<CBlockIndex*, CBlockIndex*> m_blocks_unlinked;
448448

449+
bool LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
450+
449451
/**
450452
* Load the blocktree off disk and into memory. Populate certain metadata
451453
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
@@ -798,8 +800,6 @@ class CChainState
798800
void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
799801
void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
800802

801-
bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
802-
803803
//! Indirection necessary to make lock annotations work with an optional mempool.
804804
RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs)
805805
{

0 commit comments

Comments
 (0)