mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
validation: Remove global ::ActivateBestChain
Instead use CChainState::ActivateBestChain, which is what the global one calls anyway.
This commit is contained in:
parent
2a696472a1
commit
5f8cd7b3a5
5 changed files with 9 additions and 18 deletions
|
@ -1700,7 +1700,7 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
|
|||
} // release cs_main before calling ActivateBestChain
|
||||
if (need_activate_chain) {
|
||||
BlockValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams, a_recent_block)) {
|
||||
if (!::ChainstateActive().ActivateBestChain(state, chainparams, a_recent_block)) {
|
||||
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", state.ToString());
|
||||
}
|
||||
}
|
||||
|
@ -2960,7 +2960,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||
a_recent_block = most_recent_block;
|
||||
}
|
||||
BlockValidationState state;
|
||||
if (!ActivateBestChain(state, m_chainparams, a_recent_block)) {
|
||||
if (!::ChainstateActive().ActivateBestChain(state, m_chainparams, a_recent_block)) {
|
||||
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", state.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1603,7 +1603,7 @@ static RPCHelpMan invalidateblock()
|
|||
InvalidateBlock(state, Params(), pblockindex);
|
||||
|
||||
if (state.IsValid()) {
|
||||
ActivateBestChain(state, Params());
|
||||
::ChainstateActive().ActivateBestChain(state, Params());
|
||||
}
|
||||
|
||||
if (!state.IsValid()) {
|
||||
|
@ -1643,7 +1643,7 @@ static RPCHelpMan reconsiderblock()
|
|||
}
|
||||
|
||||
BlockValidationState state;
|
||||
ActivateBestChain(state, Params());
|
||||
::ChainstateActive().ActivateBestChain(state, Params());
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
||||
|
|
|
@ -185,7 +185,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
|||
}
|
||||
|
||||
BlockValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams)) {
|
||||
if (!::ChainstateActive().ActivateBestChain(state, chainparams)) {
|
||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
||||
}
|
||||
|
||||
|
|
|
@ -2899,10 +2899,6 @@ bool CChainState::ActivateBestChain(BlockValidationState &state, const CChainPar
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ActivateBestChain(BlockValidationState &state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock) {
|
||||
return ::ChainstateActive().ActivateBestChain(state, chainparams, std::move(pblock));
|
||||
}
|
||||
|
||||
bool CChainState::PreciousBlock(BlockValidationState& state, const CChainParams& params, CBlockIndex *pindex)
|
||||
{
|
||||
{
|
||||
|
@ -4681,7 +4677,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
|
|||
// Activate the genesis block so normal node progress can continue
|
||||
if (hash == chainparams.GetConsensus().hashGenesisBlock) {
|
||||
BlockValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams, nullptr)) {
|
||||
if (!::ChainstateActive().ActivateBestChain(state, chainparams, nullptr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,13 +167,6 @@ void StopScriptCheckWorkerThreads();
|
|||
* @returns The tx if found, otherwise nullptr
|
||||
*/
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock);
|
||||
/**
|
||||
* Find the best known block, and make it the tip of the block chain
|
||||
*
|
||||
* May not be called with cs_main held. May not be called in a
|
||||
* validationinterface callback.
|
||||
*/
|
||||
bool ActivateBestChain(BlockValidationState& state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>());
|
||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||
|
||||
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
|
||||
|
@ -648,6 +641,8 @@ public:
|
|||
void PruneAndFlush();
|
||||
|
||||
/**
|
||||
* Find the best known block, and make it the tip of the block chain
|
||||
*
|
||||
* Make the best chain active, in multiple steps. The result is either failure
|
||||
* or an activated best chain. pblock is either nullptr or a pointer to a block
|
||||
* that is already loaded (to avoid loading it again from disk).
|
||||
|
@ -664,7 +659,7 @@ public:
|
|||
bool ActivateBestChain(
|
||||
BlockValidationState& state,
|
||||
const CChainParams& chainparams,
|
||||
std::shared_ptr<const CBlock> pblock) LOCKS_EXCLUDED(cs_main);
|
||||
std::shared_ptr<const CBlock> pblock = nullptr) LOCKS_EXCLUDED(cs_main);
|
||||
|
||||
bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue