chain: skip all preliminary verification when using checkpoints.

This commit is contained in:
Christopher Jeffrey 2017-03-06 18:03:56 -08:00
parent 6d477b7588
commit eeeff1f795
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -231,9 +231,26 @@ Chain.prototype.verify = co(function* verify(block, prev, flags) {
assert(typeof flags === 'number');
// Extra sanity check.
if (block.prevBlock !== prev.hash)
throw new VerifyError(block, 'invalid', 'bad-prevblk', 0);
// Skip everything when using checkpoints.
// We can do this safely because every
// block in between each checkpoint was
// validated outside in the header chain.
if (prev.isHistorical()) {
if (this.options.spv)
return new DeploymentState();
// Once segwit is active, we will still
// need to check for block mutability.
if (!block.hasWitness() && !block.getCommitmentHash())
return new DeploymentState();
flags &= ~common.flags.VERIFY_BODY;
}
// Non-contextual checks.
if (flags & common.flags.VERIFY_BODY) {
if (!block.verifyBody(ret)) {