Skip to content

Commit

Permalink
fix: deduplicate checkpoints (#304)
Browse files Browse the repository at this point in the history
If there are multiple events in single block we should only add one entry
into preloadBlocks. Otherwise it will cause `next` to be called multiple times
for the same block.
  • Loading branch information
Sekhmet authored Jun 27, 2024
1 parent 65ea05e commit a6c7e58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/checkpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default class Checkpoint {
this.preloadStep = Math.max(BLOCK_RELOAD_MIN_RANGE, this.preloadStep + increase);

if (checkpoints.length > 0) {
this.preloadedBlocks = checkpoints.map(cp => cp.blockNumber).sort();
this.preloadedBlocks = [...new Set(checkpoints.map(cp => cp.blockNumber).sort())];
return this.preloadedBlocks.shift() as number;
}

Expand Down

0 comments on commit a6c7e58

Please sign in to comment.