@@ -859,11 +859,9 @@ pub(super) struct ChannelContext<Signer: ChannelSigner> {
859
859
/// [`SignerProvider::derive_channel_signer`].
860
860
channel_keys_id : [ u8 ; 32 ] ,
861
861
862
- /// When we generate [`ChannelMonitorUpdate`]s to persist, they may not be persisted immediately.
863
- /// If we then persist the [`channelmanager::ChannelManager`] and crash before the persistence
864
- /// completes we still need to be able to complete the persistence. Thus, we have to keep a
865
- /// copy of the [`ChannelMonitorUpdate`] here until it is complete.
866
- pending_monitor_updates : Vec < PendingChannelMonitorUpdate > ,
862
+ /// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
863
+ /// store it here and only release it to [`ChannelManager`] once it asks for it.
864
+ blocked_monitor_updates : Vec < PendingChannelMonitorUpdate > ,
867
865
}
868
866
869
867
impl < Signer : ChannelSigner > ChannelContext < Signer > {
@@ -2254,7 +2252,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2254
2252
}
2255
2253
2256
2254
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 {
2257
- let release_cs_monitor = self . context . pending_monitor_updates . is_empty ( ) ;
2255
+ let release_cs_monitor = self . context . blocked_monitor_updates . is_empty ( ) ;
2258
2256
match self . get_update_fulfill_htlc ( htlc_id, payment_preimage, logger) {
2259
2257
UpdateFulfillFetch :: NewClaim { mut monitor_update, htlc_value_msat, msg } => {
2260
2258
// Even if we aren't supposed to let new monitor updates with commitment state
@@ -2269,16 +2267,16 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2269
2267
self . context . latest_monitor_update_id = monitor_update. update_id ;
2270
2268
monitor_update. updates . append ( & mut additional_update. updates ) ;
2271
2269
} else {
2272
- let new_mon_id = self . context . pending_monitor_updates . get ( 0 )
2270
+ let new_mon_id = self . context . blocked_monitor_updates . get ( 0 )
2273
2271
. map ( |upd| upd. update . update_id ) . unwrap_or ( monitor_update. update_id ) ;
2274
2272
monitor_update. update_id = new_mon_id;
2275
- for held_update in self . context . pending_monitor_updates . iter_mut ( ) {
2273
+ for held_update in self . context . blocked_monitor_updates . iter_mut ( ) {
2276
2274
held_update. update . update_id += 1 ;
2277
2275
}
2278
2276
if msg. is_some ( ) {
2279
2277
debug_assert ! ( false , "If there is a pending blocked monitor we should have MonitorUpdateInProgress set" ) ;
2280
2278
let update = self . build_commitment_no_status_check ( logger) ;
2281
- self . context . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
2279
+ self . context . blocked_monitor_updates . push ( PendingChannelMonitorUpdate {
2282
2280
update,
2283
2281
} ) ;
2284
2282
}
@@ -4397,25 +4395,25 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4397
4395
4398
4396
/// Gets the latest [`ChannelMonitorUpdate`] ID which has been released and is in-flight.
4399
4397
pub fn get_latest_unblocked_monitor_update_id ( & self ) -> u64 {
4400
- if self . context . pending_monitor_updates . is_empty ( ) { return self . context . get_latest_monitor_update_id ( ) ; }
4401
- self . context . pending_monitor_updates [ 0 ] . update . update_id - 1
4398
+ if self . context . blocked_monitor_updates . is_empty ( ) { return self . context . get_latest_monitor_update_id ( ) ; }
4399
+ self . context . blocked_monitor_updates [ 0 ] . update . update_id - 1
4402
4400
}
4403
4401
4404
4402
/// Returns the next blocked monitor update, if one exists, and a bool which indicates a
4405
4403
/// further blocked monitor update exists after the next.
4406
4404
pub fn unblock_next_blocked_monitor_update ( & mut self ) -> Option < ( ChannelMonitorUpdate , bool ) > {
4407
- if self . context . pending_monitor_updates . is_empty ( ) { return None ; }
4408
- Some ( ( self . context . pending_monitor_updates . remove ( 0 ) . update ,
4409
- !self . context . pending_monitor_updates . is_empty ( ) ) )
4405
+ if self . context . blocked_monitor_updates . is_empty ( ) { return None ; }
4406
+ Some ( ( self . context . blocked_monitor_updates . remove ( 0 ) . update ,
4407
+ !self . context . blocked_monitor_updates . is_empty ( ) ) )
4410
4408
}
4411
4409
4412
4410
/// Pushes a new monitor update into our monitor update queue, returning it if it should be
4413
4411
/// immediately given to the user for persisting or `None` if it should be held as blocked.
4414
4412
fn push_ret_blockable_mon_update ( & mut self , update : ChannelMonitorUpdate )
4415
4413
-> Option < ChannelMonitorUpdate > {
4416
- let release_monitor = self . context . pending_monitor_updates . is_empty ( ) ;
4414
+ let release_monitor = self . context . blocked_monitor_updates . is_empty ( ) ;
4417
4415
if !release_monitor {
4418
- self . context . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
4416
+ self . context . blocked_monitor_updates . push ( PendingChannelMonitorUpdate {
4419
4417
update,
4420
4418
} ) ;
4421
4419
None
@@ -4425,7 +4423,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4425
4423
}
4426
4424
4427
4425
pub fn blocked_monitor_updates_pending ( & self ) -> usize {
4428
- self . context . pending_monitor_updates . len ( )
4426
+ self . context . blocked_monitor_updates . len ( )
4429
4427
}
4430
4428
4431
4429
/// Returns true if the channel is awaiting the persistence of the initial ChannelMonitor.
@@ -5570,7 +5568,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
5570
5568
channel_type,
5571
5569
channel_keys_id,
5572
5570
5573
- pending_monitor_updates : Vec :: new ( ) ,
5571
+ blocked_monitor_updates : Vec :: new ( ) ,
5574
5572
}
5575
5573
} )
5576
5574
}
@@ -6200,7 +6198,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
6200
6198
channel_type,
6201
6199
channel_keys_id,
6202
6200
6203
- pending_monitor_updates : Vec :: new ( ) ,
6201
+ blocked_monitor_updates : Vec :: new ( ) ,
6204
6202
}
6205
6203
} ;
6206
6204
@@ -6766,7 +6764,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6766
6764
( 28 , holder_max_accepted_htlcs, option) ,
6767
6765
( 29 , self . context. temporary_channel_id, option) ,
6768
6766
( 31 , channel_pending_event_emitted, option) ,
6769
- ( 33 , self . context. pending_monitor_updates , vec_type) ,
6767
+ ( 33 , self . context. blocked_monitor_updates , vec_type) ,
6770
6768
} ) ;
6771
6769
6772
6770
Ok ( ( ) )
@@ -7043,7 +7041,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7043
7041
let mut temporary_channel_id: Option < [ u8 ; 32 ] > = None ;
7044
7042
let mut holder_max_accepted_htlcs: Option < u16 > = None ;
7045
7043
7046
- let mut pending_monitor_updates = Some ( Vec :: new ( ) ) ;
7044
+ let mut blocked_monitor_updates = Some ( Vec :: new ( ) ) ;
7047
7045
7048
7046
read_tlv_fields ! ( reader, {
7049
7047
( 0 , announcement_sigs, option) ,
@@ -7067,7 +7065,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7067
7065
( 28 , holder_max_accepted_htlcs, option) ,
7068
7066
( 29 , temporary_channel_id, option) ,
7069
7067
( 31 , channel_pending_event_emitted, option) ,
7070
- ( 33 , pending_monitor_updates , vec_type) ,
7068
+ ( 33 , blocked_monitor_updates , vec_type) ,
7071
7069
} ) ;
7072
7070
7073
7071
let ( channel_keys_id, holder_signer) = if let Some ( channel_keys_id) = channel_keys_id {
@@ -7239,7 +7237,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7239
7237
channel_type : channel_type. unwrap ( ) ,
7240
7238
channel_keys_id,
7241
7239
7242
- pending_monitor_updates : pending_monitor_updates . unwrap ( ) ,
7240
+ blocked_monitor_updates : blocked_monitor_updates . unwrap ( ) ,
7243
7241
}
7244
7242
} )
7245
7243
}
0 commit comments