merkleblock: improve extractTree perf.
This commit is contained in:
parent
594b39de66
commit
8e6819714b
@ -196,7 +196,7 @@ MerkleBlock.prototype.extractTree = function extractTree() {
|
|||||||
var indexes = [];
|
var indexes = [];
|
||||||
var map = {};
|
var map = {};
|
||||||
var failed = false;
|
var failed = false;
|
||||||
var hashes = [];
|
var hashes = this.hashes;
|
||||||
var flags = this.flags;
|
var flags = this.flags;
|
||||||
var totalTX = this.totalTX;
|
var totalTX = this.totalTX;
|
||||||
var height = 0;
|
var height = 0;
|
||||||
@ -253,15 +253,12 @@ MerkleBlock.prototype.extractTree = function extractTree() {
|
|||||||
if (totalTX > consensus.MAX_BLOCK_SIZE / 60)
|
if (totalTX > consensus.MAX_BLOCK_SIZE / 60)
|
||||||
throw new Error('Too many transactions.');
|
throw new Error('Too many transactions.');
|
||||||
|
|
||||||
if (this.hashes.length > totalTX)
|
if (hashes.length > totalTX)
|
||||||
throw new Error('Too many hashes.');
|
throw new Error('Too many hashes.');
|
||||||
|
|
||||||
if (flags.length * 8 < this.hashes.length)
|
if (flags.length * 8 < hashes.length)
|
||||||
throw new Error('Flags too small.');
|
throw new Error('Flags too small.');
|
||||||
|
|
||||||
for (p = 0; p < this.hashes.length; p++)
|
|
||||||
hashes.push(this.hashes[p]);
|
|
||||||
|
|
||||||
while (width(height) > 1)
|
while (width(height) > 1)
|
||||||
height++;
|
height++;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user