@@ -4154,9 +4154,9 @@ void BlockManager::Unload() {
4154
4154
m_block_index.clear ();
4155
4155
}
4156
4156
4157
- bool static LoadBlockIndexDB (const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
4157
+ bool static LoadBlockIndexDB (ChainstateManager& chainman, const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
4158
4158
{
4159
- if (!g_chainman .m_blockman .LoadBlockIndex (
4159
+ if (!chainman .m_blockman .LoadBlockIndex (
4160
4160
chainparams.GetConsensus (), *pblocktree,
4161
4161
::ChainstateActive ().setBlockIndexCandidates)) {
4162
4162
return false ;
@@ -4182,8 +4182,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_RE
4182
4182
// Check presence of blk files
4183
4183
LogPrintf (" Checking all blk files are present...\n " );
4184
4184
std::set<int > setBlkDataFiles;
4185
- for (const std::pair<const uint256, CBlockIndex*>& item : g_chainman.BlockIndex ())
4186
- {
4185
+ for (const std::pair<const uint256, CBlockIndex*>& item : chainman.BlockIndex ()) {
4187
4186
CBlockIndex* pindex = item.second ;
4188
4187
if (pindex->nStatus & BLOCK_HAVE_DATA) {
4189
4188
setBlkDataFiles.insert (pindex->nFile );
@@ -4600,14 +4599,15 @@ void UnloadBlockIndex()
4600
4599
fHavePruned = false ;
4601
4600
}
4602
4601
4603
- bool LoadBlockIndex (const CChainParams& chainparams)
4602
+ bool ChainstateManager:: LoadBlockIndex (const CChainParams& chainparams)
4604
4603
{
4604
+ AssertLockHeld (cs_main);
4605
4605
// Load block index from databases
4606
4606
bool needs_init = fReindex ;
4607
4607
if (!fReindex ) {
4608
- bool ret = LoadBlockIndexDB (chainparams);
4608
+ bool ret = LoadBlockIndexDB (* this , chainparams);
4609
4609
if (!ret) return false ;
4610
- needs_init = g_chainman. m_blockman .m_block_index .empty ();
4610
+ needs_init = m_blockman.m_block_index .empty ();
4611
4611
}
4612
4612
4613
4613
if (needs_init) {
0 commit comments