MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ProcessNewBlock

Function ProcessNewBlock

src/validation.cpp:3795–3826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3793}
3794
3795bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing, bool *fNewBlock)
3796{
3797 AssertLockNotHeld(cs_main);
3798
3799 {
3800 CBlockIndex *pindex = nullptr;
3801 if (fNewBlock) *fNewBlock = false;
3802 CValidationState state;
3803 // Ensure that CheckBlock() passes before calling AcceptBlock, as
3804 // belt-and-suspenders.
3805 bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus());
3806
3807 LOCK(cs_main);
3808
3809 if (ret) {
3810 // Store to disk
3811 ret = g_chainstate.AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock);
3812 }
3813 if (!ret) {
3814 GetMainSignals().BlockChecked(*pblock, state);
3815 return error("%s: AcceptBlock FAILED (%s)", __func__, FormatStateMessage(state));
3816 }
3817 }
3818
3819 NotifyHeaderTip();
3820
3821 CValidationState state; // Only used to report errors, not invalidity - ignore it
3822 if (!g_chainstate.ActivateBestChain(state, chainparams, pblock))
3823 return error("%s: ActivateBestChain failed (%s)", __func__, FormatStateMessage(state));
3824
3825 return true;
3826}
3827
3828bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
3829{

Callers 7

ProcessMessageFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
CreateAndProcessBlockMethod · 0.85
generateBlocksFunction · 0.85
submitblockFunction · 0.85
MineBlockFunction · 0.85

Calls 6

CheckBlockFunction · 0.85
errorFunction · 0.85
FormatStateMessageFunction · 0.85
AcceptBlockMethod · 0.80
ActivateBestChainMethod · 0.80
BlockCheckedMethod · 0.45

Tested by 3

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
CreateAndProcessBlockMethod · 0.68