merkleblock/minerblock: fix hasTX calls.

This commit is contained in:
Christopher Jeffrey 2017-02-28 09:32:17 -08:00
parent 45952a4140
commit 56ccfaa980
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 4 additions and 3 deletions

View File

@ -62,7 +62,7 @@ exports.thresholdStates = {
exports.flags = { exports.flags = {
VERIFY_NONE: 0, VERIFY_NONE: 0,
VERIFY_POW: 1 << 0, VERIFY_POW: 1 << 0,
VERIFY_BODY: 1 << 1, VERIFY_BODY: 1 << 1
}; };
/** /**

View File

@ -353,11 +353,12 @@ MinerBlock.prototype.extraNonce = function extraNonce() {
*/ */
MinerBlock.prototype.addTX = function addTX(tx, view) { MinerBlock.prototype.addTX = function addTX(tx, view) {
var hash = tx.hash('hex');
var item, weight, sigops; var item, weight, sigops;
assert(!tx.mutable, 'Cannot add mutable TX to block.'); assert(!tx.mutable, 'Cannot add mutable TX to block.');
if (this.block.hasTX(tx)) if (this.block.hasTX(hash))
return false; return false;
item = BlockEntry.fromTX(tx, view, this); item = BlockEntry.fromTX(tx, view, this);

View File

@ -2153,7 +2153,7 @@ Pool.prototype._handleTX = co(function* handleTX(peer, packet) {
if (peer.merkleBlock) { if (peer.merkleBlock) {
assert(peer.merkleMatches > 0); assert(peer.merkleMatches > 0);
if (peer.merkleBlock.hasTX(tx)) { if (peer.merkleBlock.hasTX(hash)) {
peer.merkleBlock.addTX(tx); peer.merkleBlock.addTX(tx);
if (--peer.merkleMatches === 0) { if (--peer.merkleMatches === 0) {
yield this._addBlock(peer, peer.merkleBlock, flags); yield this._addBlock(peer, peer.merkleBlock, flags);