8686
8787 /// Handles the next batch index in the batch index queue, pushing the future in the pipeline
8888 /// futures.
89- fn handle_next_batch <
90- F : FnMut ( & mut FuturesOrdered < DerivationPipelineFuture > , DerivationPipelineFuture ) ,
91- > (
92- & mut self ,
93- mut queue_fut : F ,
94- ) {
89+ fn handle_next_batch ( & mut self ) -> Option < DerivationPipelineFuture > {
9590 let database = self . database . clone ( ) ;
9691 let provider = self . l1_provider . clone ( ) ;
9792
@@ -105,8 +100,9 @@ where
105100
106101 derive ( batch, provider) . await . map_err ( |err| ( index, err) )
107102 } ) ;
108- queue_fut ( & mut self . pipeline_futures , fut) ;
103+ return Some ( fut) ;
109104 }
105+ None
110106 }
111107}
112108
@@ -133,7 +129,9 @@ where
133129
134130 // if the futures can still grow, handle the next batch.
135131 if this. pipeline_futures . len ( ) < MAX_CONCURRENT_DERIVATION_PIPELINE_FUTS {
136- this. handle_next_batch ( |queue, fut| queue. push_back ( fut) ) ;
132+ if let Some ( fut) = this. handle_next_batch ( ) {
133+ this. pipeline_futures . push_back ( fut)
134+ }
137135 }
138136
139137 // poll the futures and handle result.
@@ -147,7 +145,9 @@ where
147145 tracing:: error!( target: "scroll::node::derivation_pipeline" , ?index, ?err, "failed to derive payload attributes for batch" ) ;
148146 // retry polling the same batch index.
149147 this. batch_index_queue . push_front ( index) ;
150- this. handle_next_batch ( |queue, fut| queue. push_front ( fut) ) ;
148+ if let Some ( fut) = this. handle_next_batch ( ) {
149+ this. pipeline_futures . push_front ( fut)
150+ }
151151 }
152152 }
153153 }
0 commit comments