@@ -481,13 +481,12 @@ pub(crate) const EXPIRE_PREV_CONFIG_TICKS: usize = 5;
481
481
482
482
struct PendingChannelMonitorUpdate {
483
483
update : ChannelMonitorUpdate ,
484
- /// In some cases we need to delay letting the [`ChannelMonitorUpdate`] fly until after an
485
- /// `Event` is processed by the user. This bool indicates the [`ChannelMonitorUpdate`] has
486
- /// flown and we're waiting to hear back, otherwise the update is waiting on some external
487
- /// event and the [`ChannelManager`] will update us when we're ready.
484
+ /// In some cases we need to delay letting the [`ChannelMonitorUpdate`] go until after an
485
+ /// `Event` is processed by the user. This bool indicates the [`ChannelMonitorUpdate`] is
486
+ /// blocked on some externl event and the [`ChannelManager`] will update us when we're ready.
488
487
///
489
488
/// [`ChannelManager`]: super::channelmanager::ChannelManager
490
- flown : bool ,
489
+ blocked : bool ,
491
490
}
492
491
493
492
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
@@ -1988,48 +1987,48 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1988
1987
}
1989
1988
1990
1989
pub fn get_update_fulfill_htlc_and_commit < L : Deref > ( & mut self , htlc_id : u64 , payment_preimage : PaymentPreimage , logger : & L ) -> UpdateFulfillCommitFetch where L :: Target : Logger {
1991
- let fly_cs_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
1990
+ let release_cs_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
1992
1991
match self . get_update_fulfill_htlc ( htlc_id, payment_preimage, logger) {
1993
1992
UpdateFulfillFetch :: NewClaim { mut monitor_update, htlc_value_msat, msg } => {
1994
1993
// Even if we aren't supposed to let new monitor updates with commitment state
1995
- // updates fly , we still need to push the preimage ChannelMonitorUpdateStep no
1994
+ // updates run , we still need to push the preimage ChannelMonitorUpdateStep no
1996
1995
// matter what. Sadly, to push a new monitor update which flies before others
1997
1996
// already queued, we have to insert it into the pending queue and update the
1998
1997
// update_ids of all the following monitors.
1999
- let flown_monitor_pos = if fly_cs_monitor && msg. is_some ( ) {
1998
+ let unblocked_monitor_pos = if release_cs_monitor && msg. is_some ( ) {
2000
1999
// build_commitment_no_status_check may bump latest_monitor_id but we want them to be
2001
2000
// strictly increasing by one, so decrement it here.
2002
2001
let mut additional_update = self . build_commitment_no_status_check ( logger) ;
2003
2002
self . latest_monitor_update_id = monitor_update. update_id ;
2004
2003
monitor_update. updates . append ( & mut additional_update. updates ) ;
2005
2004
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
2006
- update : monitor_update, flown : true ,
2005
+ update : monitor_update, blocked : false ,
2007
2006
} ) ;
2008
2007
self . pending_monitor_updates . len ( ) - 1
2009
2008
} else {
2010
- let insert_pos = self . pending_monitor_updates . iter ( ) . position ( |upd| ! upd. flown )
2009
+ let insert_pos = self . pending_monitor_updates . iter ( ) . position ( |upd| upd. blocked )
2011
2010
. unwrap_or ( self . pending_monitor_updates . len ( ) ) ;
2012
2011
let new_mon_id = self . pending_monitor_updates . get ( insert_pos)
2013
2012
. map ( |upd| upd. update . update_id ) . unwrap_or ( monitor_update. update_id ) ;
2014
2013
monitor_update. update_id = new_mon_id;
2015
2014
self . pending_monitor_updates . insert ( insert_pos, PendingChannelMonitorUpdate {
2016
- update : monitor_update, flown : true ,
2015
+ update : monitor_update, blocked : false ,
2017
2016
} ) ;
2018
2017
for held_update in self . pending_monitor_updates . iter_mut ( ) . skip ( insert_pos + 1 ) {
2019
2018
held_update. update . update_id += 1 ;
2020
2019
}
2021
2020
if msg. is_some ( ) {
2022
- debug_assert ! ( false , "If there is a pending unflown monitor we should have MonitorUpdateInProgress set" ) ;
2021
+ debug_assert ! ( false , "If there is a pending blocked monitor we should have MonitorUpdateInProgress set" ) ;
2023
2022
let update = self . build_commitment_no_status_check ( logger) ;
2024
2023
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
2025
- update, flown : false ,
2024
+ update, blocked : true ,
2026
2025
} ) ;
2027
2026
}
2028
2027
insert_pos
2029
2028
} ;
2030
2029
self . monitor_updating_paused ( false , msg. is_some ( ) , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
2031
2030
UpdateFulfillCommitFetch :: NewClaim {
2032
- monitor_update : & self . pending_monitor_updates . get ( flown_monitor_pos )
2031
+ monitor_update : & self . pending_monitor_updates . get ( unblocked_monitor_pos )
2033
2032
. expect ( "We just pushed the monitor update" ) . update ,
2034
2033
htlc_value_msat,
2035
2034
}
@@ -3277,11 +3276,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3277
3276
}
3278
3277
log_debug ! ( logger, "Received valid commitment_signed from peer in channel {}, updated HTLC state but awaiting a monitor update resolution to reply." ,
3279
3278
log_bytes!( self . channel_id) ) ;
3280
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3279
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3281
3280
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3282
- update : monitor_update, flown : fly_monitor
3281
+ update : monitor_update, blocked : !release_monitor
3283
3282
} ) ;
3284
- return Ok ( if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ;
3283
+ return Ok ( if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ;
3285
3284
}
3286
3285
3287
3286
let need_commitment_signed = if need_commitment && ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 ) ) == 0 {
@@ -3298,12 +3297,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3298
3297
3299
3298
log_debug ! ( logger, "Received valid commitment_signed from peer in channel {}, updating HTLC state and responding with{} a revoke_and_ack." ,
3300
3299
log_bytes!( self . channel_id( ) ) , if need_commitment_signed { " our own commitment_signed and" } else { "" } ) ;
3301
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3300
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3302
3301
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3303
- update : monitor_update, flown : fly_monitor ,
3302
+ update : monitor_update, blocked : !release_monitor ,
3304
3303
} ) ;
3305
3304
self . monitor_updating_paused ( true , need_commitment_signed, false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
3306
- return Ok ( if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ;
3305
+ return Ok ( if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ;
3307
3306
}
3308
3307
3309
3308
/// Public version of the below, checking relevant preconditions first.
@@ -3418,11 +3417,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3418
3417
update_add_htlcs. len( ) , update_fulfill_htlcs. len( ) , update_fail_htlcs. len( ) ) ;
3419
3418
3420
3419
self . monitor_updating_paused ( false , true , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
3421
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3420
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3422
3421
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3423
- update : monitor_update, flown : fly_monitor ,
3422
+ update : monitor_update, blocked : !release_monitor ,
3424
3423
} ) ;
3425
- ( if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ,
3424
+ ( if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ,
3426
3425
htlcs_to_fail)
3427
3426
} else {
3428
3427
( None , Vec :: new ( ) )
@@ -3631,12 +3630,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3631
3630
self . monitor_pending_failures . append ( & mut revoked_htlcs) ;
3632
3631
self . monitor_pending_finalized_fulfills . append ( & mut finalized_claimed_htlcs) ;
3633
3632
log_debug ! ( logger, "Received a valid revoke_and_ack for channel {} but awaiting a monitor update resolution to reply." , log_bytes!( self . channel_id( ) ) ) ;
3634
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3633
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3635
3634
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3636
- update : monitor_update, flown : fly_monitor ,
3635
+ update : monitor_update, blocked : !release_monitor ,
3637
3636
} ) ;
3638
3637
return Ok ( ( Vec :: new ( ) ,
3639
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ) ;
3638
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) ) ;
3640
3639
}
3641
3640
3642
3641
match self . free_holding_cell_htlcs ( logger) {
@@ -3648,12 +3647,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3648
3647
monitor_update. updates . append ( & mut additional_update. updates ) ;
3649
3648
3650
3649
self . monitor_updating_paused ( false , true , false , to_forward_infos, revoked_htlcs, finalized_claimed_htlcs) ;
3651
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3650
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3652
3651
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3653
- update : monitor_update, flown : fly_monitor ,
3652
+ update : monitor_update, blocked : !release_monitor ,
3654
3653
} ) ;
3655
3654
Ok ( ( htlcs_to_fail,
3656
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3655
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3657
3656
} ,
3658
3657
( None , htlcs_to_fail) => {
3659
3658
if require_commitment {
@@ -3667,21 +3666,21 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3667
3666
log_debug ! ( logger, "Received a valid revoke_and_ack for channel {}. Responding with a commitment update with {} HTLCs failed." ,
3668
3667
log_bytes!( self . channel_id( ) ) , update_fail_htlcs. len( ) + update_fail_malformed_htlcs. len( ) ) ;
3669
3668
self . monitor_updating_paused ( false , true , false , to_forward_infos, revoked_htlcs, finalized_claimed_htlcs) ;
3670
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3669
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3671
3670
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3672
- update : monitor_update, flown : fly_monitor ,
3671
+ update : monitor_update, blocked : !release_monitor ,
3673
3672
} ) ;
3674
3673
Ok ( ( htlcs_to_fail,
3675
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3674
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3676
3675
} else {
3677
3676
log_debug ! ( logger, "Received a valid revoke_and_ack for channel {} with no reply necessary." , log_bytes!( self . channel_id( ) ) ) ;
3678
3677
self . monitor_updating_paused ( false , false , false , to_forward_infos, revoked_htlcs, finalized_claimed_htlcs) ;
3679
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
3678
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
3680
3679
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
3681
- update : monitor_update, flown : fly_monitor ,
3680
+ update : monitor_update, blocked : !release_monitor ,
3682
3681
} ) ;
3683
3682
Ok ( ( htlcs_to_fail,
3684
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3683
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } ) )
3685
3684
}
3686
3685
}
3687
3686
}
@@ -3870,11 +3869,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3870
3869
{
3871
3870
assert_eq ! ( self . channel_state & ChannelState :: MonitorUpdateInProgress as u32 , ChannelState :: MonitorUpdateInProgress as u32 ) ;
3872
3871
self . channel_state &= !( ChannelState :: MonitorUpdateInProgress as u32 ) ;
3873
- let mut found_unflown = false ;
3872
+ let mut found_blocked = false ;
3874
3873
self . pending_monitor_updates . retain ( |upd| {
3875
- if found_unflown { debug_assert ! ( ! upd. flown , "No mons may fly after one is paused " ) ; }
3876
- if ! upd. flown { found_unflown = true ; }
3877
- ! upd. flown
3874
+ if found_blocked { debug_assert ! ( upd. blocked , "No mons may be unblocked after a blocked one " ) ; }
3875
+ if upd. blocked { found_blocked = true ; }
3876
+ upd. blocked
3878
3877
} ) ;
3879
3878
3880
3879
// If we're past (or at) the FundingSent stage on an outbound channel, try to
@@ -4418,11 +4417,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4418
4417
} ] ,
4419
4418
} ;
4420
4419
self . monitor_updating_paused ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4421
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
4420
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
4422
4421
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
4423
- update : monitor_update, flown : fly_monitor ,
4422
+ update : monitor_update, blocked : !release_monitor ,
4424
4423
} ) ;
4425
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None }
4424
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None }
4426
4425
} else { None } ;
4427
4426
let shutdown = if send_shutdown {
4428
4427
Some ( msgs:: Shutdown {
@@ -4994,12 +4993,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4994
4993
( self . channel_state & ChannelState :: MonitorUpdateInProgress as u32 ) != 0
4995
4994
}
4996
4995
4997
- /// Returns the next unflown monitor update, if one exists, and a bool which indicates a
4998
- /// further unflown monitor update exists after the next.
4999
- pub fn fly_next_unflown_monitor_update ( & mut self ) -> Option < ( & ChannelMonitorUpdate , bool ) > {
4996
+ /// Returns the next blocked monitor update, if one exists, and a bool which indicates a
4997
+ /// further blocked monitor update exists after the next.
4998
+ pub fn unblock_next_blocked_monitor_update ( & mut self ) -> Option < ( & ChannelMonitorUpdate , bool ) > {
5000
4999
for i in 0 ..self . pending_monitor_updates . len ( ) {
5001
- if ! self . pending_monitor_updates [ i] . flown {
5002
- self . pending_monitor_updates [ i] . flown = true ;
5000
+ if self . pending_monitor_updates [ i] . blocked {
5001
+ self . pending_monitor_updates [ i] . blocked = false ;
5003
5002
return Some ( ( & self . pending_monitor_updates [ i] . update ,
5004
5003
self . pending_monitor_updates . len ( ) > i + 1 ) ) ;
5005
5004
}
@@ -6061,11 +6060,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
6061
6060
let monitor_update = self . build_commitment_no_status_check ( logger) ;
6062
6061
self . monitor_updating_paused ( false , true , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
6063
6062
6064
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
6063
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
6065
6064
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
6066
- update : monitor_update, flown : fly_monitor ,
6065
+ update : monitor_update, blocked : !release_monitor ,
6067
6066
} ) ;
6068
- Ok ( if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } )
6067
+ Ok ( if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None } )
6069
6068
} ,
6070
6069
None => Ok ( None )
6071
6070
}
@@ -6154,11 +6153,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
6154
6153
} ] ,
6155
6154
} ;
6156
6155
self . monitor_updating_paused ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
6157
- let fly_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| upd. flown ) ;
6156
+ let release_monitor = self . pending_monitor_updates . iter ( ) . all ( |upd| ! upd. blocked ) ;
6158
6157
self . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
6159
- update : monitor_update, flown : fly_monitor ,
6158
+ update : monitor_update, blocked : !release_monitor ,
6160
6159
} ) ;
6161
- if fly_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None }
6160
+ if release_monitor { self . pending_monitor_updates . last ( ) . map ( |upd| & upd. update ) } else { None }
6162
6161
} else { None } ;
6163
6162
let shutdown = msgs:: Shutdown {
6164
6163
channel_id : self . channel_id ,
0 commit comments