@@ -306,39 +306,36 @@ impl SP1AvailLightClientOperator {
306306 async fn run ( & mut self , loop_delay_mins : u64 ) -> Result < ( ) > {
307307 info ! ( "Starting SP1 Helios operator for Avail" ) ;
308308
309- loop {
310- // Get the current slot from the contract
311- let start = Instant :: now ( ) ;
312- let slot = self . get_head ( ) . await ?;
313- info ! ( "Current slot: {}" , slot) ;
314-
315- // Fetch the checkpoint at that slot
316- let checkpoint = get_checkpoint ( slot) . await ;
317-
318- // Get the client from the checkpoint
319- let client = get_client ( checkpoint) . await ;
320-
321- // Request an update
322- match self . request_update ( client) . await {
323- Ok ( Some ( proof) ) => {
324- self . relay_vector_update ( proof) . await ?;
325- }
326- Ok ( None ) => {
327- // Contract is up to date. Nothing to update.
328- }
329- Err ( e) => {
330- error ! ( "Request for update failed: {}" , e) ;
331- info ! ( "Retrying..." ) ;
332- continue ;
333- }
334- } ;
335- let duration = start. elapsed ( ) ;
336-
337- info ! ( "duration" = duration. as_secs( ) , "Loop finished" ) ;
338-
339- info ! ( "Sleeping for {:?} minutes" , loop_delay_mins) ;
340- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 60 * loop_delay_mins) ) . await ;
341- }
309+ // Get the current slot from the contract
310+ let start = Instant :: now ( ) ;
311+ let slot = self . get_head ( ) . await ?;
312+ info ! ( "Current slot: {}" , slot) ;
313+
314+ // Fetch the checkpoint at that slot
315+ let checkpoint = get_checkpoint ( slot) . await ;
316+
317+ // Get the client from the checkpoint
318+ let client = get_client ( checkpoint) . await ;
319+
320+ // Request an update
321+ match self . request_update ( client) . await {
322+ Ok ( Some ( proof) ) => {
323+ self . relay_vector_update ( proof) . await ?;
324+ }
325+ Ok ( None ) => {
326+ // Contract is up to date. Nothing to update.
327+ }
328+ Err ( e) => {
329+ error ! ( "Request for update failed: {}" , e) ;
330+ return Err ( e) ;
331+ }
332+ } ;
333+ let duration = start. elapsed ( ) ;
334+
335+ info ! ( "duration" = duration. as_secs( ) , "Loop finished" ) ;
336+
337+ info ! ( "Sleeping for {:?} minutes" , loop_delay_mins) ;
338+ Ok ( ( ) )
342339 }
343340
344341 /// get_head reads head from the Avail chain
@@ -441,11 +438,11 @@ async fn main() -> Result<()> {
441438 . parse ( ) ?;
442439
443440 let mut operator = SP1AvailLightClientOperator :: new ( ) . await ;
444- loop {
445- if let Err ( e) = operator. run ( loop_delay_mins) . await {
446- error ! ( "Error running operator: {}" , e) ;
447- }
441+ if let Err ( e) = operator. run ( loop_delay_mins) . await {
442+ error ! ( "Error running operator: {}" , e) ;
443+ return Err ( anyhow ! ( "Error running operator: {}" , e) ) ;
448444 }
445+ Ok ( ( ) )
449446}
450447
451448#[ cfg( test) ]
0 commit comments