| 4211 | } |
| 4212 | |
| 4213 | bool TestBlockValidity(BlockValidationState& state, |
| 4214 | const CChainParams& chainparams, |
| 4215 | CChainState& chainstate, |
| 4216 | const CBlock& block, |
| 4217 | CBlockIndex* pindexPrev, |
| 4218 | bool fCheckPOW, |
| 4219 | bool fCheckMerkleRoot) |
| 4220 | { |
| 4221 | AssertLockHeld(cs_main); |
| 4222 | assert(pindexPrev && pindexPrev == chainstate.m_chain.Tip()); |
| 4223 | CCoinsViewCache viewNew(&chainstate.CoinsTip()); |
| 4224 | uint256 block_hash(block.GetHash()); |
| 4225 | CBlockIndex indexDummy(block); |
| 4226 | indexDummy.pprev = pindexPrev; |
| 4227 | indexDummy.nHeight = pindexPrev->nHeight + 1; |
| 4228 | indexDummy.phashBlock = &block_hash; |
| 4229 | |
| 4230 | // NOTE: CheckBlockHeader is called by CheckBlock |
| 4231 | if (!ContextualCheckBlockHeader(block, state, chainstate.m_blockman, chainparams, pindexPrev, GetAdjustedTime())) |
| 4232 | return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, state.ToString()); |
| 4233 | if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot)) |
| 4234 | return error("%s: Consensus::CheckBlock: %s", __func__, state.ToString()); |
| 4235 | if (!ContextualCheckBlock(block, state, chainparams.GetConsensus(), pindexPrev)) |
| 4236 | return error("%s: Consensus::ContextualCheckBlock: %s", __func__, state.ToString()); |
| 4237 | if (!chainstate.ConnectBlock(block, state, &indexDummy, viewNew, NULL, true)) { |
| 4238 | return false; |
| 4239 | } |
| 4240 | assert(state.IsValid()); |
| 4241 | |
| 4242 | return true; |
| 4243 | } |
| 4244 | |
| 4245 | /* This function is called from the RPC code for pruneblockchain */ |
| 4246 | void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight) |
no test coverage detected