@@ -3429,59 +3429,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
34293429 self . process_background_events ( ) ;
34303430 }
34313431
3432- fn update_channel_fee ( & self , pending_msg_events : & mut Vec < events :: MessageSendEvent > , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> ( bool , NotifyOption , Result < ( ) , MsgHandleErrInternal > ) {
3433- if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3432+ fn update_channel_fee ( & self , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> NotifyOption {
3433+ if !chan. is_outbound ( ) { return NotifyOption :: SkipPersist ; }
34343434 // If the feerate has decreased by less than half, don't bother
34353435 if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
34363436 log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
34373437 log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3438- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3438+ return NotifyOption :: SkipPersist ;
34393439 }
34403440 if !chan. is_live ( ) {
34413441 log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {} as it cannot currently be updated (probably the peer is disconnected)." ,
34423442 log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3443- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3443+ return NotifyOption :: SkipPersist ;
34443444 }
34453445 log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
34463446 log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
34473447
3448- let mut retain_channel = true ;
3449- let res = match chan. send_update_fee_and_commit ( new_feerate, & self . logger ) {
3450- Ok ( res) => Ok ( res) ,
3451- Err ( e) => {
3452- let ( drop, res) = convert_chan_err ! ( self , e, chan, chan_id) ;
3453- if drop { retain_channel = false ; }
3454- Err ( res)
3455- }
3456- } ;
3457- let ret_err = match res {
3458- Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) ) => {
3459- match self . chain_monitor . update_channel ( chan. get_funding_txo ( ) . unwrap ( ) , monitor_update) {
3460- ChannelMonitorUpdateStatus :: Completed => {
3461- pending_msg_events. push ( events:: MessageSendEvent :: UpdateHTLCs {
3462- node_id : chan. get_counterparty_node_id ( ) ,
3463- updates : msgs:: CommitmentUpdate {
3464- update_add_htlcs : Vec :: new ( ) ,
3465- update_fulfill_htlcs : Vec :: new ( ) ,
3466- update_fail_htlcs : Vec :: new ( ) ,
3467- update_fail_malformed_htlcs : Vec :: new ( ) ,
3468- update_fee : Some ( update_fee) ,
3469- commitment_signed,
3470- } ,
3471- } ) ;
3472- Ok ( ( ) )
3473- } ,
3474- e => {
3475- let ( res, drop) = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , chan_id, COMMITMENT_UPDATE_ONLY ) ;
3476- if drop { retain_channel = false ; }
3477- res
3478- }
3479- }
3480- } ,
3481- Ok ( None ) => Ok ( ( ) ) ,
3482- Err ( e) => Err ( e) ,
3483- } ;
3484- ( retain_channel, NotifyOption :: DoPersist , ret_err)
3448+ chan. queue_update_fee ( new_feerate, & self . logger ) ;
3449+ NotifyOption :: DoPersist
34853450 }
34863451
34873452 #[ cfg( fuzzing) ]
@@ -3495,19 +3460,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
34953460
34963461 let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
34973462
3498- let mut handle_errors = Vec :: new ( ) ;
3499- {
3500- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3501- let channel_state = & mut * channel_state_lock;
3502- let pending_msg_events = & mut channel_state. pending_msg_events ;
3503- channel_state. by_id . retain ( |chan_id, chan| {
3504- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3505- if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3506- if err. is_err ( ) {
3507- handle_errors. push ( err) ;
3508- }
3509- retain_channel
3510- } ) ;
3463+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3464+ for ( chan_id, chan) in channel_state. by_id . iter_mut ( ) {
3465+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3466+ if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
35113467 }
35123468
35133469 should_persist
@@ -3572,20 +3528,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
35723528
35733529 let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
35743530
3575- let mut handle_errors = Vec :: new ( ) ;
3531+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
35763532 let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
35773533 {
35783534 let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
35793535 let channel_state = & mut * channel_state_lock;
35803536 let pending_msg_events = & mut channel_state. pending_msg_events ;
35813537 channel_state. by_id . retain ( |chan_id, chan| {
3582- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
3583- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3538+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
35843539 if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3585- if err. is_err ( ) {
3586- handle_errors. push ( ( err, counterparty_node_id) ) ;
3587- }
3588- if !retain_channel { return false ; }
35893540
35903541 if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
35913542 let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments