diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index ecafb236..c21d16cb 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -232,14 +232,11 @@ Block.prototype._checkBlock = function checkBlock() { this.merkleTree = this._buildMerkle(); // Check for duplicate tx ids - var unique = []; + var unique = {}; for (var i = 0; i < this.txs.length; i++) { - if (!~unique.indexOf(this.txs[i].hash('hex'))) { - unique.push(this.txs[i].hash('hex')); - } - } - if (unique.length !== this.txs.length) { - return false; + var hash = this.txs[i].hash('hex'); + if (unique[hash]) return false; + unique[hash] = true; } // Check to make sure block does not have more opcodes than MAX_BLOCK_SIGOPS