some consensus stuff.

This commit is contained in:
Christopher Jeffrey 2016-04-19 03:05:42 -07:00
parent 81d2e1b700
commit 53fb6dc8d5
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 25 additions and 11 deletions

View File

@ -326,8 +326,8 @@ Block.prototype.__defineGetter__('commitmentHash', function() {
*/
Block.prototype._verify = function _verify(ret) {
var uniq = {};
var i, tx, hash;
var sigops = 0;
var i, tx, merkle;
if (!ret)
ret = {};
@ -361,18 +361,32 @@ Block.prototype._verify = function _verify(ret) {
return false;
}
// Check for duplicate txids
hash = tx.hash('hex');
if (uniq[hash]) {
ret.reason = 'bad-txns-duplicate';
ret.score = 100;
// Sanity checks
if (!tx.isSane(ret))
return false;
}
uniq[hash] = true;
// Count legacy sigops (do not count scripthash or witness)
// sigops += tx._getSigops();
// if (sigops > constants.block.MAX_SIGOPS) {
// return callback(new VerifyError(block,
// 'invalid',
// 'bad-blk-sigops',
// 100));
// }
}
// Check merkle root
if (this.merkleRoot !== this.getMerkleRoot('hex')) {
merkle = this.getMerkleRoot('hex');
// If the merkle is mutated,
// we have duplicate txs.
if (!merkle) {
ret.reason = 'bad-txns-duplicate';
ret.score = 100;
return false;
}
if (this.merkleRoot !== merkle) {
ret.reason = 'bad-txnmrkleroot';
ret.score = 100;
return false;

View File

@ -822,7 +822,7 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
// Check for block sigops limits
// Start counting P2SH sigops once block
// timestamps reach March 31st, 2012.
if (block.ts >= constants.block.BIP16_TIME)
if (flags & constants.flags.VERIFY_P2SH)
sigops += tx.getSigops(true);
else
sigops += tx.getSigops();