merkleblock: improve extractTree perf.

This commit is contained in:
Christopher Jeffrey 2017-01-26 11:23:55 -08:00
parent 594b39de66
commit 8e6819714b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -196,7 +196,7 @@ MerkleBlock.prototype.extractTree = function extractTree() {
var indexes = [];
var map = {};
var failed = false;
var hashes = [];
var hashes = this.hashes;
var flags = this.flags;
var totalTX = this.totalTX;
var height = 0;
@ -253,15 +253,12 @@ MerkleBlock.prototype.extractTree = function extractTree() {
if (totalTX > consensus.MAX_BLOCK_SIZE / 60)
throw new Error('Too many transactions.');
if (this.hashes.length > totalTX)
if (hashes.length > totalTX)
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.');
for (p = 0; p < this.hashes.length; p++)
hashes.push(this.hashes[p]);
while (width(height) > 1)
height++;