mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -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
|
} // release cs_main before calling ActivateBestChain
|
||||||
if (need_activate_chain) {
|
if (need_activate_chain) {
|
||||||
BlockValidationState state;
|
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());
|
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;
|
a_recent_block = most_recent_block;
|
||||||
}
|
}
|
||||||
BlockValidationState state;
|
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());
|
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", state.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1603,7 +1603,7 @@ static RPCHelpMan invalidateblock()
|
||||||
InvalidateBlock(state, Params(), pblockindex);
|
InvalidateBlock(state, Params(), pblockindex);
|
||||||
|
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
ActivateBestChain(state, Params());
|
::ChainstateActive().ActivateBestChain(state, Params());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.IsValid()) {
|
if (!state.IsValid()) {
|
||||||
|
@ -1643,7 +1643,7 @@ static RPCHelpMan reconsiderblock()
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
ActivateBestChain(state, Params());
|
::ChainstateActive().ActivateBestChain(state, Params());
|
||||||
|
|
||||||
if (!state.IsValid()) {
|
if (!state.IsValid()) {
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
||||||
|
|
|
@ -185,7 +185,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!ActivateBestChain(state, chainparams)) {
|
if (!::ChainstateActive().ActivateBestChain(state, chainparams)) {
|
||||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2899,10 +2899,6 @@ bool CChainState::ActivateBestChain(BlockValidationState &state, const CChainPar
|
||||||
return true;
|
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)
|
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
|
// Activate the genesis block so normal node progress can continue
|
||||||
if (hash == chainparams.GetConsensus().hashGenesisBlock) {
|
if (hash == chainparams.GetConsensus().hashGenesisBlock) {
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!ActivateBestChain(state, chainparams, nullptr)) {
|
if (!::ChainstateActive().ActivateBestChain(state, chainparams, nullptr)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,13 +167,6 @@ void StopScriptCheckWorkerThreads();
|
||||||
* @returns The tx if found, otherwise nullptr
|
* @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);
|
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);
|
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
|
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
|
||||||
|
@ -648,6 +641,8 @@ public:
|
||||||
void PruneAndFlush();
|
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
|
* 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
|
* 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).
|
* that is already loaded (to avoid loading it again from disk).
|
||||||
|
@ -664,7 +659,7 @@ public:
|
||||||
bool ActivateBestChain(
|
bool ActivateBestChain(
|
||||||
BlockValidationState& state,
|
BlockValidationState& state,
|
||||||
const CChainParams& chainparams,
|
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);
|
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