diff --git a/src/avalanche/test/processor_tests.cpp b/src/avalanche/test/processor_tests.cpp --- a/src/avalanche/test/processor_tests.cpp +++ b/src/avalanche/test/processor_tests.cpp @@ -225,7 +225,8 @@ const BlockHash blockHash = block.GetHash(); LOCK(cs_main); - return g_chainman.m_blockman.LookupBlockIndex(blockHash); + return Assert(fixture->m_node.chainman) + ->m_blockman.LookupBlockIndex(blockHash); } uint256 getVoteItemId(const CBlockIndex *pindex) const { @@ -902,7 +903,8 @@ const CBlockIndex *pindex; { LOCK(cs_main); - pindex = g_chainman.m_blockman.LookupBlockIndex(blockHash); + pindex = + Assert(m_node.chainman)->m_blockman.LookupBlockIndex(blockHash); } // Create nodes that supports avalanche. @@ -965,7 +967,8 @@ const CBlockIndex *pindex; { LOCK(cs_main); - pindex = g_chainman.m_blockman.LookupBlockIndex(blockHash); + pindex = + Assert(m_node.chainman)->m_blockman.LookupBlockIndex(blockHash); } // Starting the event loop. @@ -1148,7 +1151,8 @@ CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); LOCK(cs_main); - CCoinsViewCache &coins = ::ChainstateActive().CoinsTip(); + CCoinsViewCache &coins = + Assert(m_node.chainman)->ActiveChainstate().CoinsTip(); coins.AddCoin(conflictingOutpoint, Coin(CTxOut(10 * COIN, script), 10, false), false); coins.AddCoin(immatureOutpoint, @@ -1232,9 +1236,10 @@ gArgs.ForceSetArg("-avaproof", localProof->ToHex()); bilingual_str error; + ChainstateManager &chainman = *Assert(m_node.chainman); std::unique_ptr processor = Processor::MakeProcessor( - *m_node.args, *m_node.chain, m_node.connman.get(), - *Assert(m_node.chainman), *m_node.scheduler, error); + *m_node.args, *m_node.chain, m_node.connman.get(), chainman, + *m_node.scheduler, error); BOOST_CHECK(processor != nullptr); BOOST_CHECK(processor->getLocalProof() != nullptr); @@ -1302,7 +1307,7 @@ auto spendProofUtxo = [&processor](ProofRef proof) { { LOCK(cs_main); - CCoinsViewCache &coins = ::ChainstateActive().CoinsTip(); + CCoinsViewCache &coins = chainman.ActiveChainstate().CoinsTip(); coins.SpendCoin(proof->getStakes()[0].getStake().getUTXO()); } processor->withPeerManager([&proof](avalanche::PeerManager &pm) { diff --git a/src/avalanche/test/proof_tests.cpp b/src/avalanche/test/proof_tests.cpp --- a/src/avalanche/test/proof_tests.cpp +++ b/src/avalanche/test/proof_tests.cpp @@ -1032,7 +1032,7 @@ // Immature stake { - uint32_t chaintipHeight = ::ChainActive().Height(); + uint32_t chaintipHeight = chainman.ActiveHeight(); // A proof where the UTXO is both missing and immature gives // MISSING_UTXO diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -201,11 +201,11 @@ LOCK(cs_main); CBlockIndex *pblockindex = - g_chainman.m_blockman.LookupBlockIndex(hash); + chainman.m_blockman.LookupBlockIndex(hash); if (pblockindex && !pblockindex->nStatus.isValid()) { LogPrintf("Reconsidering checkpointed block %s ...\n", hash.GetHex()); - ::ChainstateActive().ResetBlockFailureFlags(pblockindex); + chainman.ActiveChainstate().ResetBlockFailureFlags(pblockindex); } } diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -352,8 +352,7 @@ gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)), m_limit_descendant_size(gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * - 1000) { - } + 1000) {} // We put the arguments we're handed into a struct, so we can pass them // around easier. @@ -718,7 +717,7 @@ Workspace workspace(ptx, GetNextBlockScriptFlags( args.m_config.GetChainParams().GetConsensus(), - ::ChainActive().Tip())); + m_active_chainstate.m_chain.Tip())); if (!PreChecks(args, workspace)) { return false; @@ -4825,7 +4824,6 @@ int nCheckDepth) { AssertLockHeld(cs_main); - const CChainParams ¶ms = config.GetChainParams(); const Consensus::Params &consensusParams = params.GetConsensus();