block: improve performance of duplicate tx check.
This commit is contained in:
parent
44774e7c6b
commit
e3e324441b
@ -232,14 +232,11 @@ Block.prototype._checkBlock = function checkBlock() {
|
|||||||
this.merkleTree = this._buildMerkle();
|
this.merkleTree = this._buildMerkle();
|
||||||
|
|
||||||
// Check for duplicate tx ids
|
// Check for duplicate tx ids
|
||||||
var unique = [];
|
var unique = {};
|
||||||
for (var i = 0; i < this.txs.length; i++) {
|
for (var i = 0; i < this.txs.length; i++) {
|
||||||
if (!~unique.indexOf(this.txs[i].hash('hex'))) {
|
var hash = this.txs[i].hash('hex');
|
||||||
unique.push(this.txs[i].hash('hex'));
|
if (unique[hash]) return false;
|
||||||
}
|
unique[hash] = true;
|
||||||
}
|
|
||||||
if (unique.length !== this.txs.length) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to make sure block does not have more opcodes than MAX_BLOCK_SIGOPS
|
// Check to make sure block does not have more opcodes than MAX_BLOCK_SIGOPS
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user