From 3dc59084c9cc5410efa54dd20207bc0ffc6ab299 Mon Sep 17 00:00:00 2001 From: Sasha <118575614+weboko@users.noreply.github.com> Date: Tue, 5 Mar 2024 23:41:38 +0100 Subject: [PATCH] fix: improve mapping over blocks (#100) --- src/contract/rln_contract.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/contract/rln_contract.ts b/src/contract/rln_contract.ts index 0533436..65ca2ed 100644 --- a/src/contract/rln_contract.ts +++ b/src/contract/rln_contract.ts @@ -206,8 +206,8 @@ export class RLNContract { indexes.forEach((index) => { if (this._members.has(index)) { this._members.delete(index); + rlnInstance.zerokit.deleteMember(index); } - rlnInstance.zerokit.deleteMember(index); }); this.merkleRootTracker.backFill(blockNumber); @@ -335,15 +335,13 @@ function splitToChunks( function* takeN(array: T[], size: number): Iterable { let start = 0; - let skip = size; - while (skip < array.length) { - const portion = array.slice(start, skip); + while (start < array.length) { + const portion = array.slice(start, start + size); yield portion; - start = skip; - skip += size; + start += size; } }