@@ -54,14 +54,14 @@ impl IntoScannerResult<RangeInclusive<BlockNumber>> for RangeInclusive<BlockNumb
5454 feature = "tracing" ,
5555 tracing:: instrument( level = "trace" , skip( subscription, sender, provider, reorg_handler) )
5656) ]
57- pub ( crate ) async fn stream_live_blocks < N : Network > (
57+ pub ( crate ) async fn stream_live_blocks < N : Network , R : ReorgHandler < N > > (
5858 stream_start : BlockNumber ,
5959 subscription : RobustSubscription < N > ,
6060 sender : & mpsc:: Sender < BlockScannerResult > ,
6161 provider : & RobustProvider < N > ,
6262 block_confirmations : u64 ,
6363 max_block_range : u64 ,
64- reorg_handler : & mut ReorgHandler < N > ,
64+ reorg_handler : & mut R ,
6565 notify_after_first_block : bool ,
6666) {
6767 // Phase 1: Wait for first relevant block
@@ -169,14 +169,14 @@ fn skip_to_first_relevant_block<N: Network>(
169169
170170/// Initializes the streaming state after receiving the first block.
171171/// Returns None if the channel is closed.
172- async fn initialize_live_streaming_state < N : Network > (
172+ async fn initialize_live_streaming_state < N : Network , R : ReorgHandler < N > > (
173173 first_block : N :: HeaderResponse ,
174174 stream_start : BlockNumber ,
175175 block_confirmations : u64 ,
176176 max_block_range : u64 ,
177177 sender : & mpsc:: Sender < BlockScannerResult > ,
178178 provider : & RobustProvider < N > ,
179- reorg_handler : & mut ReorgHandler < N > ,
179+ reorg_handler : & mut R ,
180180) -> Option < LiveStreamingState < N > > {
181181 let confirmed = first_block. number ( ) . saturating_sub ( block_confirmations) ;
182182
@@ -206,6 +206,7 @@ async fn initialize_live_streaming_state<N: Network>(
206206async fn stream_blocks_continuously <
207207 N : Network ,
208208 S : tokio_stream:: Stream < Item = Result < N :: HeaderResponse , subscription:: Error > > + Unpin ,
209+ R : ReorgHandler < N > ,
209210> (
210211 stream : & mut S ,
211212 state : & mut LiveStreamingState < N > ,
@@ -214,7 +215,7 @@ async fn stream_blocks_continuously<
214215 max_block_range : u64 ,
215216 sender : & mpsc:: Sender < BlockScannerResult > ,
216217 provider : & RobustProvider < N > ,
217- reorg_handler : & mut ReorgHandler < N > ,
218+ reorg_handler : & mut R ,
218219) {
219220 while let Some ( incoming_block) = stream. next ( ) . await {
220221 let incoming_block = match incoming_block {
@@ -337,14 +338,14 @@ async fn handle_reorg_detected<N: Network>(
337338
338339/// Streams the next batch of blocks up to `batch_end_num`.
339340/// Returns `ChannelState::Closed` if the channel is closed, `ChannelState::Open` otherwise.
340- async fn stream_next_batch < N : Network > (
341+ async fn stream_next_batch < N : Network , R : ReorgHandler < N > > (
341342 batch_end_num : BlockNumber ,
342343 state : & mut LiveStreamingState < N > ,
343344 stream_start : BlockNumber ,
344345 max_block_range : u64 ,
345346 sender : & mpsc:: Sender < BlockScannerResult > ,
346347 provider : & RobustProvider < N > ,
347- reorg_handler : & mut ReorgHandler < N > ,
348+ reorg_handler : & mut R ,
348349) -> ChannelState {
349350 if batch_end_num < state. batch_start {
350351 // No new confirmed blocks to stream yet
@@ -389,13 +390,13 @@ struct LiveStreamingState<N: Network> {
389390 feature = "tracing" ,
390391 tracing:: instrument( level = "trace" , skip( sender, provider, reorg_handler) )
391392) ]
392- pub ( crate ) async fn stream_historical_range < N : Network > (
393+ pub ( crate ) async fn stream_historical_range < N : Network , R : ReorgHandler < N > > (
393394 start : BlockNumber ,
394395 end : BlockNumber ,
395396 max_block_range : u64 ,
396397 sender : & mpsc:: Sender < BlockScannerResult > ,
397398 provider : & RobustProvider < N > ,
398- reorg_handler : & mut ReorgHandler < N > ,
399+ reorg_handler : & mut R ,
399400) -> Option < ( ) > {
400401 // NOTE: Edge case - If the chain is too young to expose finalized blocks (height < finalized
401402 // depth) just use zero.
@@ -464,14 +465,14 @@ pub(crate) async fn stream_historical_range<N: Network>(
464465 feature = "tracing" ,
465466 tracing:: instrument( level = "trace" , skip( sender, provider, reorg_handler) )
466467) ]
467- pub ( crate ) async fn stream_range_with_reorg_handling < N : Network > (
468+ pub ( crate ) async fn stream_range_with_reorg_handling < N : Network , R : ReorgHandler < N > > (
468469 min_common_ancestor : BlockNumber ,
469470 next_start_block : BlockNumber ,
470471 end : BlockNumber ,
471472 max_block_range : u64 ,
472473 sender : & mpsc:: Sender < BlockScannerResult > ,
473474 provider : & RobustProvider < N > ,
474- reorg_handler : & mut ReorgHandler < N > ,
475+ reorg_handler : & mut R ,
475476) -> Option < N :: BlockResponse > {
476477 let mut last_batch_end: Option < N :: BlockResponse > = None ;
477478 let mut iter = RangeIterator :: forward ( next_start_block, end, max_block_range) ;
0 commit comments