@@ -3428,59 +3428,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3428
3428
self . process_background_events ( ) ;
3429
3429
}
3430
3430
3431
- 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 > ) {
3432
- if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3431
+ fn update_channel_fee ( & self , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < <K :: Target as KeysInterface >:: Signer > , new_feerate : u32 ) -> NotifyOption {
3432
+ if !chan. is_outbound ( ) { return NotifyOption :: SkipPersist ; }
3433
3433
// If the feerate has decreased by less than half, don't bother
3434
3434
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
3435
3435
log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
3436
3436
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3437
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3437
+ return NotifyOption :: SkipPersist ;
3438
3438
}
3439
3439
if !chan. is_live ( ) {
3440
3440
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)." ,
3441
3441
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3442
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3442
+ return NotifyOption :: SkipPersist ;
3443
3443
}
3444
3444
log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
3445
3445
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3446
3446
3447
- let mut retain_channel = true ;
3448
- let res = match chan. send_update_fee_and_commit ( new_feerate, & self . logger ) {
3449
- Ok ( res) => Ok ( res) ,
3450
- Err ( e) => {
3451
- let ( drop, res) = convert_chan_err ! ( self , e, chan, chan_id) ;
3452
- if drop { retain_channel = false ; }
3453
- Err ( res)
3454
- }
3455
- } ;
3456
- let ret_err = match res {
3457
- Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) ) => {
3458
- match self . chain_monitor . update_channel ( chan. get_funding_txo ( ) . unwrap ( ) , monitor_update) {
3459
- ChannelMonitorUpdateStatus :: Completed => {
3460
- pending_msg_events. push ( events:: MessageSendEvent :: UpdateHTLCs {
3461
- node_id : chan. get_counterparty_node_id ( ) ,
3462
- updates : msgs:: CommitmentUpdate {
3463
- update_add_htlcs : Vec :: new ( ) ,
3464
- update_fulfill_htlcs : Vec :: new ( ) ,
3465
- update_fail_htlcs : Vec :: new ( ) ,
3466
- update_fail_malformed_htlcs : Vec :: new ( ) ,
3467
- update_fee : Some ( update_fee) ,
3468
- commitment_signed,
3469
- } ,
3470
- } ) ;
3471
- Ok ( ( ) )
3472
- } ,
3473
- e => {
3474
- let ( res, drop) = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , chan_id, COMMITMENT_UPDATE_ONLY ) ;
3475
- if drop { retain_channel = false ; }
3476
- res
3477
- }
3478
- }
3479
- } ,
3480
- Ok ( None ) => Ok ( ( ) ) ,
3481
- Err ( e) => Err ( e) ,
3482
- } ;
3483
- ( retain_channel, NotifyOption :: DoPersist , ret_err)
3447
+ chan. queue_update_fee ( new_feerate, & self . logger ) ;
3448
+ NotifyOption :: DoPersist
3484
3449
}
3485
3450
3486
3451
#[ cfg( fuzzing) ]
@@ -3494,19 +3459,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3494
3459
3495
3460
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3496
3461
3497
- let mut handle_errors = Vec :: new ( ) ;
3498
- {
3499
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3500
- let channel_state = & mut * channel_state_lock;
3501
- let pending_msg_events = & mut channel_state. pending_msg_events ;
3502
- channel_state. by_id . retain ( |chan_id, chan| {
3503
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3504
- if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3505
- if err. is_err ( ) {
3506
- handle_errors. push ( err) ;
3507
- }
3508
- retain_channel
3509
- } ) ;
3462
+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3463
+ for ( chan_id, chan) in channel_state. by_id . iter_mut ( ) {
3464
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3465
+ if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3510
3466
}
3511
3467
3512
3468
should_persist
@@ -3571,20 +3527,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3571
3527
3572
3528
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3573
3529
3574
- let mut handle_errors = Vec :: new ( ) ;
3530
+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
3575
3531
let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
3576
3532
{
3577
3533
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3578
3534
let channel_state = & mut * channel_state_lock;
3579
3535
let pending_msg_events = & mut channel_state. pending_msg_events ;
3580
3536
channel_state. by_id . retain ( |chan_id, chan| {
3581
- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
3582
- let ( retain_channel, chan_needs_persist, err) = self . update_channel_fee ( pending_msg_events, chan_id, chan, new_feerate) ;
3537
+ let chan_needs_persist = self . update_channel_fee ( chan_id, chan, new_feerate) ;
3583
3538
if chan_needs_persist == NotifyOption :: DoPersist { should_persist = NotifyOption :: DoPersist ; }
3584
- if err. is_err ( ) {
3585
- handle_errors. push ( ( err, counterparty_node_id) ) ;
3586
- }
3587
- if !retain_channel { return false ; }
3588
3539
3589
3540
if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
3590
3541
let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments