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

Function TestBlockValidity

src/validation.cpp:3828–3851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3826}
3827
3828bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
3829{
3830 AssertLockHeld(cs_main);
3831 assert(pindexPrev && pindexPrev == chainActive.Tip());
3832 CCoinsViewCache viewNew(pcoinsTip.get());
3833 uint256 block_hash(block.GetHash());
3834 CBlockIndex indexDummy(block);
3835 indexDummy.pprev = pindexPrev;
3836 indexDummy.nHeight = pindexPrev->nHeight + 1;
3837 indexDummy.phashBlock = &block_hash;
3838
3839 // NOTE: CheckBlockHeader is called by CheckBlock
3840 if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime()))
3841 return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, FormatStateMessage(state));
3842 if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot))
3843 return error("%s: Consensus::CheckBlock: %s", __func__, FormatStateMessage(state));
3844 if (!ContextualCheckBlock(block, state, chainparams.GetConsensus(), pindexPrev))
3845 return error("%s: Consensus::ContextualCheckBlock: %s", __func__, FormatStateMessage(state));
3846 if (!g_chainstate.ConnectBlock(block, state, &indexDummy, viewNew, chainparams, true))
3847 return false;
3848 assert(state.IsValid());
3849
3850 return true;
3851}
3852
3853/**
3854 * BLOCK PRUNING CODE

Callers 2

CreateNewBlockMethod · 0.85
getblocktemplateFunction · 0.85

Calls 11

GetAdjustedTimeFunction · 0.85
errorFunction · 0.85
FormatStateMessageFunction · 0.85
CheckBlockFunction · 0.85
ContextualCheckBlockFunction · 0.85
getMethod · 0.80
ConnectBlockMethod · 0.80
TipMethod · 0.45
GetHashMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected