From 4d2816e61fbcb2c653ed21bbbeaea8308c5864b6 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Wed, 19 Jun 2024 18:05:35 +0530 Subject: [PATCH] Stop processing after endBlock in watcher fill CLI --- packages/util/src/fill.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/util/src/fill.ts b/packages/util/src/fill.ts index 197db25b..3771f0af 100644 --- a/packages/util/src/fill.ts +++ b/packages/util/src/fill.ts @@ -80,12 +80,12 @@ export const fillBlocks = async ( const completePercentage = Math.round(blocksProcessed / numberOfBlocks * 100); log(`Processed ${blocksProcessed} of ${numberOfBlocks} blocks (${completePercentage}%)`); - await processBlockByNumber(jobQueue, blockNumber + 1); - - if (blockNumber + 1 >= endBlock) { - // Break the async loop when blockProgress event is for the endBlock and processing is complete. + if (blockNumber + 1 > endBlock) { + // Break the async loop when next block to be processed is more than endBlock. break; } + + await processBlockByNumber(jobQueue, blockNumber + 1); } }