@@ -4602,7 +4602,7 @@ bool LoadGenesisBlock(const CChainParams& chainparams)
4602
4602
return ::ChainstateActive ().LoadGenesisBlock (chainparams);
4603
4603
}
4604
4604
4605
- void LoadExternalBlockFile (const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp)
4605
+ void CChainState:: LoadExternalBlockFile (const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp)
4606
4606
{
4607
4607
// Map of disk positions for blocks with unknown parent (only used for reindex)
4608
4608
static std::multimap<uint256, FlatFilePos> mapBlocksUnknownParent;
@@ -4651,7 +4651,8 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
4651
4651
{
4652
4652
LOCK (cs_main);
4653
4653
// 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 )) {
4655
4656
LogPrint (BCLog::REINDEX, " %s: Out of order block %s, parent %s not known\n " , __func__, hash.ToString (),
4656
4657
block.hashPrevBlock .ToString ());
4657
4658
if (dbp)
@@ -4660,10 +4661,12 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
4660
4661
}
4661
4662
4662
4663
// 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);
4664
4666
if (!pindex || (pindex->nStatus & BLOCK_HAVE_DATA) == 0 ) {
4665
4667
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 )) {
4667
4670
nLoaded++;
4668
4671
}
4669
4672
if (state.IsError ()) {
@@ -4677,12 +4680,14 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
4677
4680
// Activate the genesis block so normal node progress can continue
4678
4681
if (hash == chainparams.GetConsensus ().hashGenesisBlock ) {
4679
4682
BlockValidationState state;
4680
- if (!::ChainstateActive ().ActivateBestChain (state, chainparams, nullptr )) {
4683
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4684
+ if (!ActivateBestChain (state, chainparams, nullptr )) {
4681
4685
break ;
4682
4686
}
4683
4687
}
4684
4688
4685
- NotifyHeaderTip (::ChainstateActive ());
4689
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4690
+ NotifyHeaderTip (*this );
4686
4691
4687
4692
// Recursively process earlier encountered successors of this block
4688
4693
std::deque<uint256> queue;
@@ -4700,15 +4705,17 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
4700
4705
head.ToString ());
4701
4706
LOCK (cs_main);
4702
4707
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 ))
4704
4710
{
4705
4711
nLoaded++;
4706
4712
queue.push_back (pblockrecursive->GetHash ());
4707
4713
}
4708
4714
}
4709
4715
range.first ++;
4710
4716
mapBlocksUnknownParent.erase (it);
4711
- NotifyHeaderTip (::ChainstateActive ());
4717
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (*this ));
4718
+ NotifyHeaderTip (*this );
4712
4719
}
4713
4720
}
4714
4721
} catch (const std::exception& e) {
0 commit comments