@@ -3449,59 +3449,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3449
3449
self . process_background_events ( ) ;
3450
3450
}
3451
3451
3452
- 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 > ) {
3453
- if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3452
+ fn update_channel_fee ( & self , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> NotifyOption {
3453
+ if !chan. is_outbound ( ) { return NotifyOption :: SkipPersist ; }
3454
3454
// If the feerate has decreased by less than half, don't bother
3455
3455
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
3456
3456
log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
3457
3457
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3458
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3458
+ return NotifyOption :: SkipPersist ;
3459
3459
}
3460
3460
if !chan. is_live ( ) {
3461
3461
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)." ,
3462
3462
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3463
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3463
+ return NotifyOption :: SkipPersist ;
3464
3464
}
3465
3465
log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
3466
3466
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3467
3467
3468
- let mut retain_channel = true ;
3469
- let res = match chan. send_update_fee_and_commit ( new_feerate, & self . logger ) {
3470
- Ok ( res) => Ok ( res) ,
3471
- Err ( e) => {
3472
- let ( drop, res) = convert_chan_err ! ( self , e, chan, chan_id) ;
3473
- if drop { retain_channel = false ; }
3474
- Err ( res)
3475
- }
3476
- } ;
3477
- let ret_err = match res {
3478
- Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) ) => {
3479
- match self . chain_monitor . update_channel ( chan. get_funding_txo ( ) . unwrap ( ) , monitor_update) {
3480
- ChannelMonitorUpdateStatus :: Completed => {
3481
- pending_msg_events. push ( events:: MessageSendEvent :: UpdateHTLCs {
3482
- node_id : chan. get_counterparty_node_id ( ) ,
3483
- updates : msgs:: CommitmentUpdate {
3484
- update_add_htlcs : Vec :: new ( ) ,
3485
- update_fulfill_htlcs : Vec :: new ( ) ,
3486
- update_fail_htlcs : Vec :: new ( ) ,
3487
- update_fail_malformed_htlcs : Vec :: new ( ) ,
3488
- update_fee : Some ( update_fee) ,
3489
- commitment_signed,
3490
- } ,
3491
- } ) ;
3492
- Ok ( ( ) )
3493
- } ,
3494
- e => {
3495
- let ( res, drop) = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , chan_id, COMMITMENT_UPDATE_ONLY ) ;
3496
- if drop { retain_channel = false ; }
3497
- res
3498
- }
3499
- }
3500
- } ,
3501
- Ok ( None ) => Ok ( ( ) ) ,
3502
- Err ( e) => Err ( e) ,
3503
- } ;
3504
- ( retain_channel, NotifyOption :: DoPersist , ret_err)
3468
+ chan. queue_update_fee ( new_feerate, & self . logger ) ;
3469
+ NotifyOption :: DoPersist
3505
3470
}
3506
3471
3507
3472
#[ cfg( fuzzing) ]
@@ -3515,19 +3480,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3515
3480
3516
3481
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3517
3482
3518
- let mut handle_errors = Vec :: new ( ) ;
3519
- {
3520
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3521
- let channel_state = & mut * channel_state_lock;
3522
- let pending_msg_events = & mut channel_state. pending_msg_events ;
3523
- channel_state. by_id . retain ( |chan_id, chan| {
3524
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3525
- if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3526
- if err. is_err ( ) {
3527
- handle_errors. push ( err) ;
3528
- }
3529
- retain_channel
3530
- } ) ;
3483
+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3484
+ for ( chan_id, chan) in channel_state. by_id . iter_mut ( ) {
3485
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3486
+ if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3531
3487
}
3532
3488
3533
3489
should_persist
@@ -3592,20 +3548,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3592
3548
3593
3549
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3594
3550
3595
- let mut handle_errors = Vec :: new ( ) ;
3551
+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
3596
3552
let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
3597
3553
{
3598
3554
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3599
3555
let channel_state = & mut * channel_state_lock;
3600
3556
let pending_msg_events = & mut channel_state. pending_msg_events ;
3601
3557
channel_state. by_id . retain ( |chan_id, chan| {
3602
- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
3603
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3558
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3604
3559
if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3605
- if err. is_err ( ) {
3606
- handle_errors. push ( ( err, counterparty_node_id) ) ;
3607
- }
3608
- if !retain_channel { return false ; }
3609
3560
3610
3561
if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
3611
3562
let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments