@@ -3586,59 +3586,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3586
3586
self . process_background_events ( ) ;
3587
3587
}
3588
3588
3589
- 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 > ) {
3590
- if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3589
+ fn update_channel_fee ( & self , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> NotifyOption {
3590
+ if !chan. is_outbound ( ) { return NotifyOption :: SkipPersist ; }
3591
3591
// If the feerate has decreased by less than half, don't bother
3592
3592
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
3593
3593
log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
3594
3594
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3595
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3595
+ return NotifyOption :: SkipPersist ;
3596
3596
}
3597
3597
if !chan. is_live ( ) {
3598
3598
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)." ,
3599
3599
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3600
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3600
+ return NotifyOption :: SkipPersist ;
3601
3601
}
3602
3602
log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
3603
3603
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3604
3604
3605
- let mut retain_channel = true ;
3606
- let res = match chan. send_update_fee_and_commit ( new_feerate, & self . logger ) {
3607
- Ok ( res) => Ok ( res) ,
3608
- Err ( e) => {
3609
- let ( drop, res) = convert_chan_err ! ( self , e, chan, chan_id) ;
3610
- if drop { retain_channel = false ; }
3611
- Err ( res)
3612
- }
3613
- } ;
3614
- let ret_err = match res {
3615
- Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) ) => {
3616
- match self . chain_monitor . update_channel ( chan. get_funding_txo ( ) . unwrap ( ) , monitor_update) {
3617
- ChannelMonitorUpdateStatus :: Completed => {
3618
- pending_msg_events. push ( events:: MessageSendEvent :: UpdateHTLCs {
3619
- node_id : chan. get_counterparty_node_id ( ) ,
3620
- updates : msgs:: CommitmentUpdate {
3621
- update_add_htlcs : Vec :: new ( ) ,
3622
- update_fulfill_htlcs : Vec :: new ( ) ,
3623
- update_fail_htlcs : Vec :: new ( ) ,
3624
- update_fail_malformed_htlcs : Vec :: new ( ) ,
3625
- update_fee : Some ( update_fee) ,
3626
- commitment_signed,
3627
- } ,
3628
- } ) ;
3629
- Ok ( ( ) )
3630
- } ,
3631
- e => {
3632
- let ( res, drop) = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , chan_id, COMMITMENT_UPDATE_ONLY ) ;
3633
- if drop { retain_channel = false ; }
3634
- res
3635
- }
3636
- }
3637
- } ,
3638
- Ok ( None ) => Ok ( ( ) ) ,
3639
- Err ( e) => Err ( e) ,
3640
- } ;
3641
- ( retain_channel, NotifyOption :: DoPersist , ret_err)
3605
+ chan. queue_update_fee ( new_feerate, & self . logger ) ;
3606
+ NotifyOption :: DoPersist
3642
3607
}
3643
3608
3644
3609
#[ cfg( fuzzing) ]
@@ -3652,19 +3617,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3652
3617
3653
3618
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3654
3619
3655
- let mut handle_errors = Vec :: new ( ) ;
3656
- {
3657
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3658
- let channel_state = & mut * channel_state_lock;
3659
- let pending_msg_events = & mut channel_state. pending_msg_events ;
3660
- channel_state. by_id . retain ( |chan_id, chan| {
3661
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3662
- if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3663
- if err. is_err ( ) {
3664
- handle_errors. push ( err) ;
3665
- }
3666
- retain_channel
3667
- } ) ;
3620
+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3621
+ for ( chan_id, chan) in channel_state. by_id . iter_mut ( ) {
3622
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3623
+ if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3668
3624
}
3669
3625
3670
3626
should_persist
@@ -3729,20 +3685,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3729
3685
3730
3686
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3731
3687
3732
- let mut handle_errors = Vec :: new ( ) ;
3688
+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
3733
3689
let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
3734
3690
{
3735
3691
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3736
3692
let channel_state = & mut * channel_state_lock;
3737
3693
let pending_msg_events = & mut channel_state. pending_msg_events ;
3738
3694
channel_state. by_id . retain ( |chan_id, chan| {
3739
- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
3740
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3695
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3741
3696
if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3742
- if err. is_err ( ) {
3743
- handle_errors. push ( ( err, counterparty_node_id) ) ;
3744
- }
3745
- if !retain_channel { return false ; }
3746
3697
3747
3698
if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
3748
3699
let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments