Skip to content

Commit 8cdb2f7

Browse files
committed
validation: Move LoadBlockIndexDB to CChainState
CChainState needed cuz setBlockIndexCandidates
1 parent 8b99efb commit 8cdb2f7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/validation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,11 +4136,12 @@ void BlockManager::Unload() {
41364136
m_block_index.clear();
41374137
}
41384138

4139-
bool static LoadBlockIndexDB(ChainstateManager& chainman, const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
4139+
bool CChainState::LoadBlockIndexDB(const CChainParams& chainparams)
41404140
{
4141-
if (!chainman.m_blockman.LoadBlockIndex(
4141+
assert(std::addressof(::ChainstateActive()) == std::addressof(*this));
4142+
if (!m_blockman.LoadBlockIndex(
41424143
chainparams.GetConsensus(), *pblocktree,
4143-
::ChainstateActive().setBlockIndexCandidates)) {
4144+
setBlockIndexCandidates)) {
41444145
return false;
41454146
}
41464147

@@ -4164,7 +4165,7 @@ bool static LoadBlockIndexDB(ChainstateManager& chainman, const CChainParams& ch
41644165
// Check presence of blk files
41654166
LogPrintf("Checking all blk files are present...\n");
41664167
std::set<int> setBlkDataFiles;
4167-
for (const std::pair<const uint256, CBlockIndex*>& item : chainman.BlockIndex()) {
4168+
for (const std::pair<const uint256, CBlockIndex*>& item : m_blockman.m_block_index) {
41684169
CBlockIndex* pindex = item.second;
41694170
if (pindex->nStatus & BLOCK_HAVE_DATA) {
41704171
setBlkDataFiles.insert(pindex->nFile);
@@ -4596,7 +4597,7 @@ bool ChainstateManager::LoadBlockIndex(const CChainParams& chainparams)
45964597
// Load block index from databases
45974598
bool needs_init = fReindex;
45984599
if (!fReindex) {
4599-
bool ret = LoadBlockIndexDB(*this, chainparams);
4600+
bool ret = ActiveChainstate().LoadBlockIndexDB(chainparams);
46004601
if (!ret) return false;
46014602
needs_init = m_blockman.m_block_index.empty();
46024603
}

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ class CChainState
776776
void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
777777
void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
778778

779+
bool LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
780+
779781
friend ChainstateManager;
780782
};
781783

0 commit comments

Comments
 (0)