@@ -4602,7 +4602,7 @@ bool LoadGenesisBlock(const CChainParams& chainparams)
46024602 return ::ChainstateActive ().LoadGenesisBlock (chainparams);
46034603}
46044604
4605- void LoadExternalBlockFile (const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp)
4605+ void CChainState:: LoadExternalBlockFile (const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp)
46064606{
46074607 // Map of disk positions for blocks with unknown parent (only used for reindex)
46084608 static std::multimap<uint256, FlatFilePos> mapBlocksUnknownParent;
@@ -4651,7 +4651,8 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
46514651 {
46524652 LOCK (cs_main);
46534653 // detect out of order blocks, and store them for later
4654- if (hash != chainparams.GetConsensus ().hashGenesisBlock && !g_chainman.m_blockman .LookupBlockIndex (block.hashPrevBlock )) {
4654+ assert (std::addressof (g_chainman.m_blockman ) == std::addressof (m_blockman));
4655+ if (hash != chainparams.GetConsensus ().hashGenesisBlock && !m_blockman.LookupBlockIndex (block.hashPrevBlock )) {
46554656 LogPrint (BCLog::REINDEX, " %s: Out of order block %s, parent %s not known\n " , __func__, hash.ToString (),
46564657 block.hashPrevBlock .ToString ());
46574658 if (dbp)
@@ -4660,10 +4661,12 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
46604661 }
46614662
46624663 // process in case the block isn't known yet
4663- CBlockIndex* pindex = g_chainman.m_blockman .LookupBlockIndex (hash);
4664+ assert (std::addressof (g_chainman.m_blockman ) == std::addressof (m_blockman));
4665+ CBlockIndex* pindex = m_blockman.LookupBlockIndex (hash);
46644666 if (!pindex || (pindex->nStatus & BLOCK_HAVE_DATA) == 0 ) {
46654667 BlockValidationState state;
4666- if (::ChainstateActive ().AcceptBlock (pblock, state, chainparams, nullptr , true , dbp, nullptr )) {
4668+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4669+ if (AcceptBlock (pblock, state, chainparams, nullptr , true , dbp, nullptr )) {
46674670 nLoaded++;
46684671 }
46694672 if (state.IsError ()) {
@@ -4677,12 +4680,14 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
46774680 // Activate the genesis block so normal node progress can continue
46784681 if (hash == chainparams.GetConsensus ().hashGenesisBlock ) {
46794682 BlockValidationState state;
4680- if (!::ChainstateActive ().ActivateBestChain (state, chainparams, nullptr )) {
4683+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4684+ if (!ActivateBestChain (state, chainparams, nullptr )) {
46814685 break ;
46824686 }
46834687 }
46844688
4685- NotifyHeaderTip (::ChainstateActive ());
4689+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4690+ NotifyHeaderTip (*this );
46864691
46874692 // Recursively process earlier encountered successors of this block
46884693 std::deque<uint256> queue;
@@ -4700,15 +4705,17 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
47004705 head.ToString ());
47014706 LOCK (cs_main);
47024707 BlockValidationState dummy;
4703- if (::ChainstateActive ().AcceptBlock (pblockrecursive, dummy, chainparams, nullptr , true , &it->second , nullptr ))
4708+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4709+ if (AcceptBlock (pblockrecursive, dummy, chainparams, nullptr , true , &it->second , nullptr ))
47044710 {
47054711 nLoaded++;
47064712 queue.push_back (pblockrecursive->GetHash ());
47074713 }
47084714 }
47094715 range.first ++;
47104716 mapBlocksUnknownParent.erase (it);
4711- NotifyHeaderTip (::ChainstateActive ());
4717+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4718+ NotifyHeaderTip (*this );
47124719 }
47134720 }
47144721 } catch (const std::exception& e) {
0 commit comments