@@ -30,8 +30,6 @@ const RETRY_INTERVAL: Duration = Duration::from_secs(5);
30
30
const BLOCK_BATCH_SIZE : u64 = 100 ;
31
31
/// How much to wait before polling the next latest block
32
32
const POLL_INTERVAL : Duration = Duration :: from_secs ( 2 ) ;
33
- /// Retry last N blocks
34
- const RETRY_PREVIOUS_BLOCKS : u64 = 100 ;
35
33
36
34
#[ derive( Debug , Clone ) ]
37
35
pub struct BlockRange {
@@ -196,13 +194,15 @@ pub async fn watch_blocks_wrapper(
196
194
chain_state : BlockchainState ,
197
195
latest_safe_block : BlockNumber ,
198
196
tx : mpsc:: Sender < BlockRange > ,
197
+ retry_previous_blocks : u64 ,
199
198
) {
200
199
let mut last_safe_block_processed = latest_safe_block;
201
200
loop {
202
201
if let Err ( e) = watch_blocks (
203
202
chain_state. clone ( ) ,
204
203
& mut last_safe_block_processed,
205
204
tx. clone ( ) ,
205
+ retry_previous_blocks,
206
206
)
207
207
. in_current_span ( )
208
208
. await
@@ -221,6 +221,7 @@ pub async fn watch_blocks(
221
221
chain_state : BlockchainState ,
222
222
last_safe_block_processed : & mut BlockNumber ,
223
223
tx : mpsc:: Sender < BlockRange > ,
224
+ retry_previous_blocks : u64 ,
224
225
) -> Result < ( ) > {
225
226
tracing:: info!( "Watching blocks to handle new events" ) ;
226
227
@@ -229,7 +230,7 @@ pub async fn watch_blocks(
229
230
230
231
let latest_safe_block = get_latest_safe_block ( & chain_state) . in_current_span ( ) . await ;
231
232
if latest_safe_block > * last_safe_block_processed {
232
- let mut from = latest_safe_block. saturating_sub ( RETRY_PREVIOUS_BLOCKS ) ;
233
+ let mut from = latest_safe_block. saturating_sub ( retry_previous_blocks ) ;
233
234
234
235
// In normal situation, the difference between latest and last safe block should not be more than 2-3 (for arbitrum it can be 10)
235
236
// TODO: add a metric for this in separate PR. We need alerts
0 commit comments