@@ -3429,59 +3429,24 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3429
3429
self . process_background_events ( ) ;
3430
3430
}
3431
3431
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 ; }
3434
3434
// If the feerate has decreased by less than half, don't bother
3435
3435
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
3436
3436
log_trace ! ( self . logger, "Channel {} does not qualify for a feerate change from {} to {}." ,
3437
3437
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3438
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3438
+ return NotifyOption :: SkipPersist ;
3439
3439
}
3440
3440
if !chan. is_live ( ) {
3441
3441
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)." ,
3442
3442
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3443
- return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ;
3443
+ return NotifyOption :: SkipPersist ;
3444
3444
}
3445
3445
log_trace ! ( self . logger, "Channel {} qualifies for a feerate change from {} to {}." ,
3446
3446
log_bytes!( chan_id[ ..] ) , chan. get_feerate( ) , new_feerate) ;
3447
3447
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
3485
3450
}
3486
3451
3487
3452
#[ cfg( fuzzing) ]
@@ -3495,19 +3460,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3495
3460
3496
3461
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3497
3462
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 ; }
3511
3467
}
3512
3468
3513
3469
should_persist
@@ -3572,20 +3528,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3572
3528
3573
3529
let new_feerate = self . fee_estimator . bounded_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
3574
3530
3575
- let mut handle_errors = Vec :: new ( ) ;
3531
+ let mut handle_errors: Vec < ( Result < ( ) , _ > , _ ) > = Vec :: new ( ) ;
3576
3532
let mut timed_out_mpp_htlcs = Vec :: new ( ) ;
3577
3533
{
3578
3534
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
3579
3535
let channel_state = & mut * channel_state_lock;
3580
3536
let pending_msg_events = & mut channel_state. pending_msg_events ;
3581
3537
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) ;
3584
3539
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 ; }
3589
3540
3590
3541
if let Err ( e) = chan. timer_check_closing_negotiation_progress ( ) {
3591
3542
let ( needs_close, err) = convert_chan_err ! ( self , e, chan, chan_id) ;
0 commit comments