Skip to content

Commit

Permalink
TOB-LSK-4: Trivial loop condition in snapshot creation (#17)
Browse files Browse the repository at this point in the history
🔨 Refactor while loop
  • Loading branch information
sameersubudhi authored Mar 20, 2024
1 parent 3d49c88 commit 8487ed0
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ async function iterate(
) {
let start = Buffer.alloc(ADDRESS_LENGTH, 0);
let lastProcessedAddress: Buffer;
do {

// eslint-disable-next-line no-constant-condition
while (true) {
const stream = rdb.iterate({
gte: Buffer.concat([prefixBuffer, start, postfixBuffer]),
lte: Buffer.concat([prefixBuffer, Buffer.alloc(ADDRESS_LENGTH, 255), postfixBuffer]),
Expand Down Expand Up @@ -74,7 +76,7 @@ async function iterate(
break;
}
start = incrementBufferWithOverflow(lastProcessedAddress);
} while (lastProcessedAddress);
}
}

export async function createSnapshot(db: StateDB, tokenId: Buffer): Promise<Account[]> {
Expand Down

0 comments on commit 8487ed0

Please sign in to comment.