From 37fe54f89a3a3188a2eef2252f11efe0d470252c Mon Sep 17 00:00:00 2001 From: zeapoz Date: Fri, 20 Oct 2023 12:30:55 +0200 Subject: [PATCH] ref: update latest l1 block on exit only --- src/l1_fetcher.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/l1_fetcher.rs b/src/l1_fetcher.rs index 3cd2183..e5f6492 100644 --- a/src/l1_fetcher.rs +++ b/src/l1_fetcher.rs @@ -232,6 +232,11 @@ impl L1Fetcher { if (disable_polling && current_l1_block_number > end_block_number) || shutdown_rx.try_recv().is_ok() { + // Store our current L1 block number so we can resume from where we left + // off. + if let Some(snapshot) = &snapshot_clone { + snapshot.lock().await.latest_l1_block_number = current_l1_block_number; + } break; } @@ -273,11 +278,6 @@ impl L1Fetcher { continue; }; - // Store our current L1 block number so we can resume if the process exits. - if let Some(snapshot) = &snapshot_clone { - snapshot.lock().await.latest_l1_block_number = current_l1_block_number; - } - metrics.lock().await.latest_l1_block_nbr = current_l1_block_number.as_u64(); // Increment current block index.