@@ -3550,59 +3550,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3550
3550
self . process_background_events ( ) ;
3551
3551
}
3552
3552
3553
- 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 > ) {
3554
- if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3553
+ fn update_channel_fee ( & self , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> NotifyOption {
3554
+ if !chan. is_outbound ( ) { return NotifyOption :: SkipPersist ; }
3555
3555
// If the feerate has decreased by less than half, don't bother
3556
3556
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
3557
3557
log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
3558
3558
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3559
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3559
+ return NotifyOption :: SkipPersist ;
3560
3560
}
3561
3561
if !chan. is_live ( ) {
3562
3562
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)." ,
3563
3563
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3564
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3564
+ return NotifyOption :: SkipPersist ;
3565
3565
}
3566
3566
log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
3567
3567
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3568
3568
3569
- let mut retain_channel = true ;
3570
- let res = match chan. send_update_fee_and_commit ( new_feerate, & self . logger ) {
3571
- Ok ( res) => Ok ( res) ,
3572
- Err ( e) => {
3573
- let ( drop, res) = convert_chan_err ! ( self , e, chan, chan_id) ;
3574
- if drop { retain_channel = false ; }
3575
- Err ( res)
3576
- }
3577
- } ;
3578
- let ret_err = match res {
3579
- Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) ) => {
3580
- match self . chain_monitor . update_channel ( chan. get_funding_txo ( ) . unwrap ( ) , monitor_update) {
3581
- ChannelMonitorUpdateStatus :: Completed => {
3582
- pending_msg_events. push ( events:: MessageSendEvent :: UpdateHTLCs {
3583
- node_id : chan. get_counterparty_node_id ( ) ,
3584
- updates : msgs:: CommitmentUpdate {
3585
- update_add_htlcs : Vec :: new ( ) ,
3586
- update_fulfill_htlcs : Vec :: new ( ) ,
3587
- update_fail_htlcs : Vec :: new ( ) ,
3588
- update_fail_malformed_htlcs : Vec :: new ( ) ,
3589
- update_fee : Some ( update_fee) ,
3590
- commitment_signed,
3591
- } ,
3592
- } ) ;
3593
- Ok ( ( ) )
3594
- } ,
3595
- e => {
3596
- let ( res, drop) = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , chan_id, COMMITMENT_UPDATE_ONLY ) ;
3597
- if drop { retain_channel = false ; }
3598
- res
3599
- }
3600
- }
3601
- } ,
3602
- Ok ( None ) => Ok ( ( ) ) ,
3603
- Err ( e) => Err ( e) ,
3604
- } ;
3605
- ( retain_channel, NotifyOption :: DoPersist , ret_err)
3569
+ chan. queue_update_fee ( new_feerate, & self . logger ) ;
3570
+ NotifyOption :: DoPersist
3606
3571
}
3607
3572
3608
3573
#[ cfg( fuzzing) ]
@@ -3616,19 +3581,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3616
3581
3617
3582
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3618
3583
3619
- let mut handle_errors = Vec :: new ( ) ;
3620
- {
3621
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3622
- let channel_state = & mut * channel_state_lock;
3623
- let pending_msg_events = & mut channel_state. pending_msg_events ;
3624
- channel_state. by_id . retain ( |chan_id, chan| {
3625
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3626
- if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3627
- if err. is_err ( ) {
3628
- handle_errors. push ( err) ;
3629
- }
3630
- retain_channel
3631
- } ) ;
3584
+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3585
+ for ( chan_id, chan) in channel_state. by_id . iter_mut ( ) {
3586
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3587
+ if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3632
3588
}
3633
3589
3634
3590
should_persist
@@ -3693,20 +3649,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3693
3649
3694
3650
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3695
3651
3696
- let mut handle_errors = Vec :: new ( ) ;
3652
+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
3697
3653
let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
3698
3654
{
3699
3655
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3700
3656
let channel_state = & mut * channel_state_lock;
3701
3657
let pending_msg_events = & mut channel_state. pending_msg_events ;
3702
3658
channel_state. by_id . retain ( |chan_id, chan| {
3703
- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
3704
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3659
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3705
3660
if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3706
- if err. is_err ( ) {
3707
- handle_errors. push ( ( err, counterparty_node_id) ) ;
3708
- }
3709
- if !retain_channel { return false ; }
3710
3661
3711
3662
if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
3712
3663
let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments