@@ -4154,9 +4154,9 @@ void BlockManager::Unload() {
41544154 m_block_index.clear ();
41554155}
41564156
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)
41584158{
4159- if (!g_chainman .m_blockman .LoadBlockIndex (
4159+ if (!chainman .m_blockman .LoadBlockIndex (
41604160 chainparams.GetConsensus (), *pblocktree,
41614161 ::ChainstateActive ().setBlockIndexCandidates)) {
41624162 return false ;
@@ -4182,8 +4182,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_RE
41824182 // Check presence of blk files
41834183 LogPrintf (" Checking all blk files are present...\n " );
41844184 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 ()) {
41874186 CBlockIndex* pindex = item.second ;
41884187 if (pindex->nStatus & BLOCK_HAVE_DATA) {
41894188 setBlkDataFiles.insert (pindex->nFile );
@@ -4600,14 +4599,15 @@ void UnloadBlockIndex()
46004599 fHavePruned = false ;
46014600}
46024601
4603- bool LoadBlockIndex (const CChainParams& chainparams)
4602+ bool ChainstateManager:: LoadBlockIndex (const CChainParams& chainparams)
46044603{
4604+ AssertLockHeld (cs_main);
46054605 // Load block index from databases
46064606 bool needs_init = fReindex ;
46074607 if (!fReindex ) {
4608- bool ret = LoadBlockIndexDB (chainparams);
4608+ bool ret = LoadBlockIndexDB (* this , chainparams);
46094609 if (!ret) return false ;
4610- needs_init = g_chainman. m_blockman .m_block_index .empty ();
4610+ needs_init = m_blockman.m_block_index .empty ();
46114611 }
46124612
46134613 if (needs_init) {
0 commit comments