diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -114,9 +114,6 @@ // Internal stuff namespace { -CBlockIndex *&pindexBestInvalid = ::ChainstateActive().pindexBestInvalid; -CBlockIndex *&pindexBestParked = ::ChainstateActive().pindexBestParked; - /** * The best finalized block. * This block cannot be reorged in any way, shape or form. @@ -858,8 +855,8 @@ } if (pindexBestForkTip || - (pindexBestInvalid && - pindexBestInvalid->nChainWork > + (::ChainstateActive().pindexBestInvalid && + ::ChainstateActive().pindexBestInvalid->nChainWork > ::ChainActive().Tip()->nChainWork + (GetBlockProof(*::ChainActive().Tip()) * 6))) { if (!GetfLargeWorkForkFound() && pindexBestForkBase) { @@ -922,9 +919,10 @@ static void InvalidChainFound(CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { AssertLockHeld(cs_main); - if (!pindexBestInvalid || - pindexNew->nChainWork > pindexBestInvalid->nChainWork) { - pindexBestInvalid = pindexNew; + if (!::ChainstateActive().pindexBestInvalid || + pindexNew->nChainWork > + ::ChainstateActive().pindexBestInvalid->nChainWork) { + ::ChainstateActive().pindexBestInvalid = pindexNew; } // If the invalid chain found is supposed to be finalized, we need to move @@ -4442,15 +4440,17 @@ } if (pindex->nStatus.isInvalid() && - (!pindexBestInvalid || - pindex->nChainWork > pindexBestInvalid->nChainWork)) { - pindexBestInvalid = pindex; + (!::ChainstateActive().pindexBestInvalid || + pindex->nChainWork > + ::ChainstateActive().pindexBestInvalid->nChainWork)) { + ::ChainstateActive().pindexBestInvalid = pindex; } if (pindex->nStatus.isOnParkedChain() && - (!pindexBestParked || - pindex->nChainWork > pindexBestParked->nChainWork)) { - pindexBestParked = pindex; + (!::ChainstateActive().pindexBestParked || + pindex->nChainWork > + ::ChainstateActive().pindexBestParked->nChainWork)) { + ::ChainstateActive().pindexBestParked = pindex; } if (pindex->pprev) { @@ -4892,8 +4892,8 @@ ::ChainActive().SetTip(nullptr); g_blockman.Unload(); pindexFinalized = nullptr; - pindexBestInvalid = nullptr; - pindexBestParked = nullptr; + ::ChainstateActive().pindexBestInvalid = nullptr; + ::ChainstateActive().pindexBestParked = nullptr; pindexBestHeader = nullptr; pindexBestForkTip = nullptr; pindexBestForkBase = nullptr;