From acc7e53b011058041872f2bb5c57dde981608471 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 6 Jul 2021 13:44:25 +0300 Subject: [PATCH] fix capacity calculation --- src/merkleTree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/merkleTree.js b/src/merkleTree.js index c4c0278..a569123 100644 --- a/src/merkleTree.js +++ b/src/merkleTree.js @@ -24,7 +24,7 @@ class MerkleTree { */ constructor(levels, elements = [], { hashFunction, zeroElement = DEFAULT_ZERO } = {}) { this.levels = levels - this.capacity = 1 << levels + this.capacity = 2 ** levels this.zeroElement = zeroElement this._hash = hashFunction || defaultHash if (elements.length > this.capacity) { @@ -177,7 +177,7 @@ class MerkleTree { static deserialize(data, hashFunction) { const instance = Object.assign(Object.create(this.prototype), data) instance._hash = hashFunction || defaultHash - instance.capacity = 1 << instance.levels + instance.capacity = 2 ** instance.levels instance.zeroElement = instance._zeros[0] return instance }