chain: skip all preliminary verification when using checkpoints.
This commit is contained in:
parent
6d477b7588
commit
eeeff1f795
@ -231,9 +231,26 @@ Chain.prototype.verify = co(function* verify(block, prev, flags) {
|
|||||||
|
|
||||||
assert(typeof flags === 'number');
|
assert(typeof flags === 'number');
|
||||||
|
|
||||||
|
// Extra sanity check.
|
||||||
if (block.prevBlock !== prev.hash)
|
if (block.prevBlock !== prev.hash)
|
||||||
throw new VerifyError(block, 'invalid', 'bad-prevblk', 0);
|
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.
|
// Non-contextual checks.
|
||||||
if (flags & common.flags.VERIFY_BODY) {
|
if (flags & common.flags.VERIFY_BODY) {
|
||||||
if (!block.verifyBody(ret)) {
|
if (!block.verifyBody(ret)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user