@@ -862,11 +862,9 @@ pub(super) struct ChannelContext<Signer: ChannelSigner> {
862
862
/// [`SignerProvider::derive_channel_signer`].
863
863
channel_keys_id : [ u8 ; 32 ] ,
864
864
865
- /// When we generate [`ChannelMonitorUpdate`]s to persist, they may not be persisted immediately.
866
- /// If we then persist the [`channelmanager::ChannelManager`] and crash before the persistence
867
- /// completes we still need to be able to complete the persistence. Thus, we have to keep a
868
- /// copy of the [`ChannelMonitorUpdate`] here until it is complete.
869
- pending_monitor_updates : Vec < PendingChannelMonitorUpdate > ,
865
+ /// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
866
+ /// store it here and only release it to [`ChannelManager`] once it asks for it.
867
+ blocked_monitor_updates : Vec < PendingChannelMonitorUpdate > ,
870
868
}
871
869
872
870
impl < Signer : ChannelSigner > ChannelContext < Signer > {
@@ -2257,7 +2255,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2257
2255
}
2258
2256
2259
2257
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 {
2260
- let release_cs_monitor = self . context . pending_monitor_updates . is_empty ( ) ;
2258
+ let release_cs_monitor = self . context . blocked_monitor_updates . is_empty ( ) ;
2261
2259
match self . get_update_fulfill_htlc ( htlc_id, payment_preimage, logger) {
2262
2260
UpdateFulfillFetch :: NewClaim { mut monitor_update, htlc_value_msat, msg } => {
2263
2261
// Even if we aren't supposed to let new monitor updates with commitment state
@@ -2272,16 +2270,16 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2272
2270
self . context . latest_monitor_update_id = monitor_update. update_id ;
2273
2271
monitor_update. updates . append ( & mut additional_update. updates ) ;
2274
2272
} else {
2275
- let new_mon_id = self . context . pending_monitor_updates . get ( 0 )
2273
+ let new_mon_id = self . context . blocked_monitor_updates . get ( 0 )
2276
2274
. map ( |upd| upd. update . update_id ) . unwrap_or ( monitor_update. update_id ) ;
2277
2275
monitor_update. update_id = new_mon_id;
2278
- for held_update in self . context . pending_monitor_updates . iter_mut ( ) {
2276
+ for held_update in self . context . blocked_monitor_updates . iter_mut ( ) {
2279
2277
held_update. update . update_id += 1 ;
2280
2278
}
2281
2279
if msg. is_some ( ) {
2282
2280
debug_assert ! ( false , "If there is a pending blocked monitor we should have MonitorUpdateInProgress set" ) ;
2283
2281
let update = self . build_commitment_no_status_check ( logger) ;
2284
- self . context . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
2282
+ self . context . blocked_monitor_updates . push ( PendingChannelMonitorUpdate {
2285
2283
update,
2286
2284
} ) ;
2287
2285
}
@@ -4406,25 +4404,25 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4406
4404
4407
4405
/// Gets the latest [`ChannelMonitorUpdate`] ID which has been released and is in-flight.
4408
4406
pub fn get_latest_unblocked_monitor_update_id ( & self ) -> u64 {
4409
- if self . context . pending_monitor_updates . is_empty ( ) { return self . context . get_latest_monitor_update_id ( ) ; }
4410
- self . context . pending_monitor_updates [ 0 ] . update . update_id - 1
4407
+ if self . context . blocked_monitor_updates . is_empty ( ) { return self . context . get_latest_monitor_update_id ( ) ; }
4408
+ self . context . blocked_monitor_updates [ 0 ] . update . update_id - 1
4411
4409
}
4412
4410
4413
4411
/// Returns the next blocked monitor update, if one exists, and a bool which indicates a
4414
4412
/// further blocked monitor update exists after the next.
4415
4413
pub fn unblock_next_blocked_monitor_update ( & mut self ) -> Option < ( ChannelMonitorUpdate , bool ) > {
4416
- if self . context . pending_monitor_updates . is_empty ( ) { return None ; }
4417
- Some ( ( self . context . pending_monitor_updates . remove ( 0 ) . update ,
4418
- !self . context . pending_monitor_updates . is_empty ( ) ) )
4414
+ if self . context . blocked_monitor_updates . is_empty ( ) { return None ; }
4415
+ Some ( ( self . context . blocked_monitor_updates . remove ( 0 ) . update ,
4416
+ !self . context . blocked_monitor_updates . is_empty ( ) ) )
4419
4417
}
4420
4418
4421
4419
/// Pushes a new monitor update into our monitor update queue, returning it if it should be
4422
4420
/// immediately given to the user for persisting or `None` if it should be held as blocked.
4423
4421
fn push_ret_blockable_mon_update ( & mut self , update : ChannelMonitorUpdate )
4424
4422
-> Option < ChannelMonitorUpdate > {
4425
- let release_monitor = self . context . pending_monitor_updates . is_empty ( ) ;
4423
+ let release_monitor = self . context . blocked_monitor_updates . is_empty ( ) ;
4426
4424
if !release_monitor {
4427
- self . context . pending_monitor_updates . push ( PendingChannelMonitorUpdate {
4425
+ self . context . blocked_monitor_updates . push ( PendingChannelMonitorUpdate {
4428
4426
update,
4429
4427
} ) ;
4430
4428
None
@@ -4434,7 +4432,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4434
4432
}
4435
4433
4436
4434
pub fn blocked_monitor_updates_pending ( & self ) -> usize {
4437
- self . context . pending_monitor_updates . len ( )
4435
+ self . context . blocked_monitor_updates . len ( )
4438
4436
}
4439
4437
4440
4438
/// Returns true if the channel is awaiting the persistence of the initial ChannelMonitor.
@@ -5590,7 +5588,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
5590
5588
channel_type,
5591
5589
channel_keys_id,
5592
5590
5593
- pending_monitor_updates : Vec :: new ( ) ,
5591
+ blocked_monitor_updates : Vec :: new ( ) ,
5594
5592
}
5595
5593
} )
5596
5594
}
@@ -6220,7 +6218,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
6220
6218
channel_type,
6221
6219
channel_keys_id,
6222
6220
6223
- pending_monitor_updates : Vec :: new ( ) ,
6221
+ blocked_monitor_updates : Vec :: new ( ) ,
6224
6222
}
6225
6223
} ;
6226
6224
@@ -6806,7 +6804,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6806
6804
( 28 , holder_max_accepted_htlcs, option) ,
6807
6805
( 29 , self . context. temporary_channel_id, option) ,
6808
6806
( 31 , channel_pending_event_emitted, option) ,
6809
- ( 33 , self . context. pending_monitor_updates , vec_type) ,
6807
+ ( 33 , self . context. blocked_monitor_updates , vec_type) ,
6810
6808
( 35 , pending_outbound_skimmed_fees, optional_vec) ,
6811
6809
( 37 , holding_cell_skimmed_fees, optional_vec) ,
6812
6810
} ) ;
@@ -7087,7 +7085,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7087
7085
let mut temporary_channel_id: Option < [ u8 ; 32 ] > = None ;
7088
7086
let mut holder_max_accepted_htlcs: Option < u16 > = None ;
7089
7087
7090
- let mut pending_monitor_updates = Some ( Vec :: new ( ) ) ;
7088
+ let mut blocked_monitor_updates = Some ( Vec :: new ( ) ) ;
7091
7089
7092
7090
let mut pending_outbound_skimmed_fees_opt: Option < Vec < Option < u64 > > > = None ;
7093
7091
let mut holding_cell_skimmed_fees_opt: Option < Vec < Option < u64 > > > = None ;
@@ -7114,7 +7112,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7114
7112
( 28 , holder_max_accepted_htlcs, option) ,
7115
7113
( 29 , temporary_channel_id, option) ,
7116
7114
( 31 , channel_pending_event_emitted, option) ,
7117
- ( 33 , pending_monitor_updates , vec_type) ,
7115
+ ( 33 , blocked_monitor_updates , vec_type) ,
7118
7116
( 35 , pending_outbound_skimmed_fees_opt, optional_vec) ,
7119
7117
( 37 , holding_cell_skimmed_fees_opt, optional_vec) ,
7120
7118
} ) ;
@@ -7307,7 +7305,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7307
7305
channel_type : channel_type. unwrap ( ) ,
7308
7306
channel_keys_id,
7309
7307
7310
- pending_monitor_updates : pending_monitor_updates . unwrap ( ) ,
7308
+ blocked_monitor_updates : blocked_monitor_updates . unwrap ( ) ,
7311
7309
}
7312
7310
} )
7313
7311
}
0 commit comments