validation: change ProcessNewBlock() to take a CBlock reference

Update ProcessNewBlock arguments to newer style.
This commit is contained in:
fanquake committed 2021-05-31 14:36:46 +08:00
1 parent d7a6bba949
commit 610151f5b0
2 files changed
+13 -14

No files matched your search

+6 -6
View File
@@ -3591,14 +3591,14 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
return true; return true;
} }
bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing, bool* fNewBlock) bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock>& block, bool force_processing, bool* new_block)
{ {
AssertLockNotHeld(cs_main); AssertLockNotHeld(cs_main);
assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate())); assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate()));
{ {
CBlockIndex *pindex = nullptr; CBlockIndex *pindex = nullptr;
if (fNewBlock) *fNewBlock = false; if (new_block) *new_block = false;
BlockValidationState state; BlockValidationState state;
// CheckBlock() does not support multi-threaded block validation because CBlock::fChecked can cause data race. // CheckBlock() does not support multi-threaded block validation because CBlock::fChecked can cause data race.
@@ -3607,13 +3607,13 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
// Ensure that CheckBlock() passes before calling AcceptBlock, as // Ensure that CheckBlock() passes before calling AcceptBlock, as
// belt-and-suspenders. // belt-and-suspenders.
bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus()); bool ret = CheckBlock(*block, state, chainparams.GetConsensus());
if (ret) { if (ret) {
// Store to disk // Store to disk
ret = ActiveChainstate().AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock); ret = ActiveChainstate().AcceptBlock(block, state, chainparams, &pindex, force_processing, nullptr, new_block);
} }
if (!ret) { if (!ret) {
GetMainSignals().BlockChecked(*pblock, state); GetMainSignals().BlockChecked(*block, state);
return error("%s: AcceptBlock FAILED (%s)", __func__, state.ToString()); return error("%s: AcceptBlock FAILED (%s)", __func__, state.ToString());
} }
} }
@@ -3621,7 +3621,7 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
NotifyHeaderTip(ActiveChainstate()); NotifyHeaderTip(ActiveChainstate());
BlockValidationState state; // Only used to report errors, not invalidity - ignore it BlockValidationState state; // Only used to report errors, not invalidity - ignore it
if (!ActiveChainstate().ActivateBestChain(state, chainparams, pblock)) if (!ActiveChainstate().ActivateBestChain(state, chainparams, block))
return error("%s: ActivateBestChain failed (%s)", __func__, state.ToString()); return error("%s: ActivateBestChain failed (%s)", __func__, state.ToString());
return true; return true;
+7 -8
View File
@@ -970,22 +970,21 @@ public:
* block is made active. Note that it does not, however, guarantee that the * block is made active. Note that it does not, however, guarantee that the
* specific block passed to it has been checked for validity! * specific block passed to it has been checked for validity!
* *
* If you want to *possibly* get feedback on whether pblock is valid, you must * If you want to *possibly* get feedback on whether block is valid, you must
* install a CValidationInterface (see validationinterface.h) - this will have * install a CValidationInterface (see validationinterface.h) - this will have
* its BlockChecked method called whenever *any* block completes validation. * its BlockChecked method called whenever *any* block completes validation.
* *
* Note that we guarantee that either the proof-of-work is valid on pblock, or * Note that we guarantee that either the proof-of-work is valid on block, or
* (and possibly also) BlockChecked will have been called. * (and possibly also) BlockChecked will have been called.
* *
* May not be called in a * May not be called in a validationinterface callback.
* validationinterface callback.
* *
* @param[in] pblock The block we want to process. * @param[in] block The block we want to process.
* @param[in] fForceProcessing Process this block even if unrequested; used for non-network block sources. * @param[in] force_processing Process this block even if unrequested; used for non-network block sources.
* @param[out] fNewBlock A boolean which is set to indicate if the block was first received via this call * @param[out] new_block A boolean which is set to indicate if the block was first received via this call
* @returns If the block was processed, independently of block validity * @returns If the block was processed, independently of block validity
*/ */
bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing, bool* fNewBlock) LOCKS_EXCLUDED(cs_main); bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock>& block, bool force_processing, bool* new_block) LOCKS_EXCLUDED(cs_main);
/** /**
* Process incoming block headers. * Process incoming block headers.