remove old getMerkleRoot.

This commit is contained in:
Christopher Jeffrey 2016-02-23 17:08:55 -08:00
parent 0fac957da3
commit 36e8d75faf

View File

@ -201,38 +201,6 @@ Block.prototype._verifyPartial = function _verifyPartial() {
return true;
};
Block.prototype.getMerkleRoot = function getMerkleRoot() {
var tree = [];
var i, j, size, i2, hash;
assert(this.subtype === 'block');
for (i = 0; i < this.txs.length; i++)
tree.push(this.txs[i].hash());
j = 0;
size = this.txs.length;
for (; size > 1; size = ((size + 1) / 2) | 0) {
for (i = 0; i < size; i += 2) {
i2 = Math.min(i + 1, size - 1);
if (i2 === i + 1 && i2 + 1 === size
&& tree[j + i] === tree[j + i2]) {
return utils.toHex(constants.zeroHash);
}
hash = Buffer.concat([tree[j + i], tree[j + i2]]);
hash = utils.dsha256(hash);
tree.push(hash);
}
j += size;
}
if (!tree.length)
return utils.toHex(constants.zeroHash);
return utils.toHex(tree[tree.length - 1]);
};
Block.prototype.getMerkleRoot = function getMerkleRoot() {
var hashes = [];
var i;