From 2488cc6b1c97bcbcb6e2ce3272907aade078df9b Mon Sep 17 00:00:00 2001 From: trevormil Date: Fri, 31 Mar 2023 16:25:11 -0400 Subject: [PATCH] make fillDefaultHash more efficient --- src/MerkleTree.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/MerkleTree.ts b/src/MerkleTree.ts index cd7d726..6f36e8e 100644 --- a/src/MerkleTree.ts +++ b/src/MerkleTree.ts @@ -143,10 +143,8 @@ export class MerkleTree extends Base { } if (this.fillDefaultHash) { - for (let i = 0; i < Math.pow(2, Math.ceil(Math.log2(this.leaves.length))); i++) { - if (i >= this.leaves.length) { - this.leaves.push(this.bufferify(this.fillDefaultHash(i, this.hashFn))) - } + for (let i = this.leaves.length; i < Math.pow(2, Math.ceil(Math.log2(this.leaves.length))); i++) { + this.leaves.push(this.bufferify(this.fillDefaultHash(i, this.hashFn))) } }