| 3633 | } |
| 3634 | |
| 3635 | bool 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 |
no test coverage detected