@@ -397,11 +397,13 @@ where
397397 /// If `delay_until_height` is set, we will delay the spending until the respective block
398398 /// height is reached. This can be used to batch spends, e.g., to reduce on-chain fees.
399399 ///
400+ /// Returns `Err` on persistence failure, in which case the call may be safely retried.
401+ ///
400402 /// [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs
401403 pub fn track_spendable_outputs (
402404 & self , output_descriptors : Vec < SpendableOutputDescriptor > , channel_id : Option < ChannelId > ,
403405 exclude_static_outputs : bool , delay_until_height : Option < u32 > ,
404- ) {
406+ ) -> Result < ( ) , ( ) > {
405407 let mut relevant_descriptors = output_descriptors
406408 . into_iter ( )
407409 . filter ( |desc| {
@@ -411,10 +413,10 @@ where
411413 . peekable ( ) ;
412414
413415 if relevant_descriptors. peek ( ) . is_none ( ) {
414- return ;
416+ return Ok ( ( ) ) ;
415417 }
416418
417- let mut spending_tx_opt;
419+ let spending_tx_opt;
418420 {
419421 let mut state_lock = self . sweeper_state . lock ( ) . unwrap ( ) ;
420422 for descriptor in relevant_descriptors {
@@ -438,16 +440,16 @@ where
438440 state_lock. outputs . push ( output_info) ;
439441 }
440442 spending_tx_opt = self . regenerate_spend_if_necessary ( & mut * state_lock) ;
441- self . persist_state ( & * state_lock) . unwrap_or_else ( |e| {
443+ self . persist_state ( & * state_lock) . map_err ( |e| {
442444 log_error ! ( self . logger, "Error persisting OutputSweeper: {:?}" , e) ;
443- // Skip broadcasting if the persist failed.
444- spending_tx_opt = None ;
445- } ) ;
445+ } ) ?;
446446 }
447447
448448 if let Some ( spending_tx) = spending_tx_opt {
449449 self . broadcaster . broadcast_transactions ( & [ & spending_tx] ) ;
450450 }
451+
452+ Ok ( ( ) )
451453 }
452454
453455 /// Returns a list of the currently tracked spendable outputs.
0 commit comments