fix spv.
This commit is contained in:
parent
b85a98b4ca
commit
d1aaaefda1
@ -471,16 +471,23 @@ Chain.prototype._verify = function _verify(block, prev, callback) {
|
|||||||
if (!block.verify(ret))
|
if (!block.verify(ret))
|
||||||
return callback(new VerifyError(block, 'invalid', ret.reason, ret.score));
|
return callback(new VerifyError(block, 'invalid', ret.reason, ret.score));
|
||||||
|
|
||||||
if (this.options.spv || block.type !== 'block')
|
// Skip the genesis block. Skip all blocks in spv mode.
|
||||||
return callback(null, constants.flags.MANDATORY_VERIFY_FLAGS);
|
if (this.options.spv || block.isGenesis()) {
|
||||||
|
return callback(null, {
|
||||||
// Skip the genesis block
|
flags: constants.flags.MANDATORY_VERIFY_FLAGS,
|
||||||
if (block.isGenesis())
|
lockFlags: constants.flags.MANDATORY_LOCKTIME_FLAGS,
|
||||||
return callback(null, constants.flags.MANDATORY_VERIFY_FLAGS);
|
segwit: false,
|
||||||
|
csv: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure it's not an orphan
|
// Ensure it's not an orphan
|
||||||
if (!prev)
|
if (!prev) {
|
||||||
return callback(new VerifyError(block, 'invalid', 'bad-prevblk', 0));
|
return callback(new VerifyError(block,
|
||||||
|
'invalid',
|
||||||
|
'bad-prevblk',
|
||||||
|
0));
|
||||||
|
}
|
||||||
|
|
||||||
prev.getRetargetAncestors(function(err, ancestors) {
|
prev.getRetargetAncestors(function(err, ancestors) {
|
||||||
if (err)
|
if (err)
|
||||||
@ -513,7 +520,7 @@ Chain.prototype._verify = function _verify(block, prev, callback) {
|
|||||||
self.segwitActive = state.segwit;
|
self.segwitActive = state.segwit;
|
||||||
|
|
||||||
// Can't verify any further when merkleblock or headers.
|
// Can't verify any further when merkleblock or headers.
|
||||||
if (block.type !== 'block')
|
if (this.options.spv)
|
||||||
return callback(null, state.flags);
|
return callback(null, state.flags);
|
||||||
|
|
||||||
// Make sure the height contained in the coinbase is correct.
|
// Make sure the height contained in the coinbase is correct.
|
||||||
@ -718,7 +725,7 @@ Chain.prototype._checkDuplicates = function _checkDuplicates(block, prev, callba
|
|||||||
var self = this;
|
var self = this;
|
||||||
var height = prev.height + 1;
|
var height = prev.height + 1;
|
||||||
|
|
||||||
if (this.options.spv || block.type !== 'block')
|
if (this.options.spv)
|
||||||
return callback();
|
return callback();
|
||||||
|
|
||||||
if (block.isGenesis())
|
if (block.isGenesis())
|
||||||
@ -804,7 +811,7 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, state, callbac
|
|||||||
var scriptCheck = true;
|
var scriptCheck = true;
|
||||||
var historical = false;
|
var historical = false;
|
||||||
|
|
||||||
if (this.options.spv || block.type !== 'block')
|
if (this.options.spv)
|
||||||
return callback();
|
return callback();
|
||||||
|
|
||||||
if (block.isGenesis())
|
if (block.isGenesis())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user