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

Function TestBlockValidity

src/main.cpp:3635–3658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3633}
3634
3635bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex * const pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
3636{
3637 AssertLockHeld(cs_main);
3638 assert(pindexPrev == chainActive.Tip());
3639
3640 CCoinsViewCache viewNew(pcoinsTip);
3641 CBlockIndex indexDummy(block);
3642 indexDummy.pprev = pindexPrev;
3643 indexDummy.nHeight = pindexPrev->nHeight + 1;
3644 indexDummy.nMaxBlockSize = GetNextMaxBlockSize(pindexPrev, Params().GetConsensus());
3645
3646 // NOTE: CheckBlockHeader is called by CheckBlock
3647 if (!ContextualCheckBlockHeader(block, state, pindexPrev))
3648 return false;
3649 if (!CheckBlock(block, state, fCheckPOW, fCheckMerkleRoot))
3650 return false;
3651 if (!ContextualCheckBlock(block, state, pindexPrev))
3652 return false;
3653 if (!ConnectBlock(block, state, &indexDummy, viewNew, true))
3654 return false;
3655 assert(state.IsValid());
3656
3657 return true;
3658}
3659
3660/**
3661 * BLOCK PRUNING CODE

Callers 2

CreateNewBlockFunction · 0.85
getblocktemplateFunction · 0.85

Calls 8

GetNextMaxBlockSizeFunction · 0.85
ContextualCheckBlockFunction · 0.85
ConnectBlockFunction · 0.85
ParamsClass · 0.70
CheckBlockFunction · 0.70
TipMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected