@@ -210,26 +210,13 @@ struct MonitorHolder<ChannelSigner: WriteableEcdsaChannelSigner> {
210
210
/// [`ChannelMonitorUpdateStatus::InProgress`], and then calls channel_monitor_updated
211
211
/// immediately, racing our insertion of the pending update into the contained Vec.
212
212
pending_monitor_updates : Mutex < Vec < MonitorUpdateId > > ,
213
- /// The last block height at which no [`UpdateOrigin::ChainSync`] monitor updates were present
214
- /// in `pending_monitor_updates`.
215
- /// If it's been more than [`LATENCY_GRACE_PERIOD_BLOCKS`] since we started waiting on a chain
216
- /// sync event, we let monitor events return to `ChannelManager` because we cannot hold them up
217
- /// forever or we'll end up with HTLC preimages waiting to feed back into an upstream channel
218
- /// forever, risking funds loss.
219
- ///
220
- /// [`LATENCY_GRACE_PERIOD_BLOCKS`]: crate::util::ser::Writeable::write
221
- last_chain_persist_height : AtomicUsize ,
222
213
}
223
214
224
215
impl < ChannelSigner : WriteableEcdsaChannelSigner > MonitorHolder < ChannelSigner > {
225
216
fn has_pending_offchain_updates ( & self , pending_monitor_updates_lock : & MutexGuard < Vec < MonitorUpdateId > > ) -> bool {
226
217
pending_monitor_updates_lock. iter ( ) . any ( |update_id|
227
218
if let UpdateOrigin :: OffChain ( _) = update_id. contents { true } else { false } )
228
219
}
229
- fn has_pending_chainsync_updates ( & self , pending_monitor_updates_lock : & MutexGuard < Vec < MonitorUpdateId > > ) -> bool {
230
- pending_monitor_updates_lock. iter ( ) . any ( |update_id|
231
- if let UpdateOrigin :: ChainSync ( _) = update_id. contents { true } else { false } )
232
- }
233
220
}
234
221
235
222
/// A read-only reference to a current ChannelMonitor.
@@ -317,7 +304,7 @@ where C::Target: chain::Filter,
317
304
for funding_outpoint in funding_outpoints. iter ( ) {
318
305
let monitor_lock = self . monitors . read ( ) . unwrap ( ) ;
319
306
if let Some ( monitor_state) = monitor_lock. get ( funding_outpoint) {
320
- if self . update_monitor_with_chain_data ( header, best_height , txdata, & process, funding_outpoint, & monitor_state) . is_err ( ) {
307
+ if self . update_monitor_with_chain_data ( header, txdata, & process, funding_outpoint, & monitor_state) . is_err ( ) {
321
308
// Take the monitors lock for writing so that we poison it and any future
322
309
// operations going forward fail immediately.
323
310
core:: mem:: drop ( monitor_lock) ;
@@ -332,7 +319,7 @@ where C::Target: chain::Filter,
332
319
let monitor_states = self . monitors . write ( ) . unwrap ( ) ;
333
320
for ( funding_outpoint, monitor_state) in monitor_states. iter ( ) {
334
321
if !funding_outpoints. contains ( funding_outpoint) {
335
- if self . update_monitor_with_chain_data ( header, best_height , txdata, & process, funding_outpoint, & monitor_state) . is_err ( ) {
322
+ if self . update_monitor_with_chain_data ( header, txdata, & process, funding_outpoint, & monitor_state) . is_err ( ) {
336
323
log_error ! ( self . logger, "{}" , err_str) ;
337
324
panic ! ( "{}" , err_str) ;
338
325
}
@@ -351,8 +338,8 @@ where C::Target: chain::Filter,
351
338
}
352
339
353
340
fn update_monitor_with_chain_data < FN > (
354
- & self , header : & Header , best_height : Option < u32 > , txdata : & TransactionData ,
355
- process : FN , funding_outpoint : & OutPoint , monitor_state : & MonitorHolder < ChannelSigner >
341
+ & self , header : & Header , txdata : & TransactionData , process : FN , funding_outpoint : & OutPoint ,
342
+ monitor_state : & MonitorHolder < ChannelSigner >
356
343
) -> Result < ( ) , ( ) > where FN : Fn ( & ChannelMonitor < ChannelSigner > , & TransactionData ) -> Vec < TransactionOutputs > {
357
344
let monitor = & monitor_state. monitor ;
358
345
let logger = WithChannelMonitor :: from ( & self . logger , & monitor) ;
@@ -364,14 +351,6 @@ where C::Target: chain::Filter,
364
351
contents : UpdateOrigin :: ChainSync ( chain_sync_update_id) ,
365
352
} ;
366
353
let mut pending_monitor_updates = monitor_state. pending_monitor_updates . lock ( ) . unwrap ( ) ;
367
- if let Some ( height) = best_height {
368
- if !monitor_state. has_pending_chainsync_updates ( & pending_monitor_updates) {
369
- // If there are not ChainSync persists awaiting completion, go ahead and
370
- // set last_chain_persist_height here - we wouldn't want the first
371
- // InProgress to always immediately be considered "overly delayed".
372
- monitor_state. last_chain_persist_height . store ( height as usize , Ordering :: Release ) ;
373
- }
374
- }
375
354
376
355
log_trace ! ( logger, "Syncing Channel Monitor for channel {} for block-data update_id {}" ,
377
356
log_funding_info!( monitor) ,
@@ -562,23 +541,7 @@ where C::Target: chain::Filter,
562
541
monitor_update_id: monitor_data. monitor. get_latest_update_id( ) ,
563
542
} ] , monitor_data. monitor . get_counterparty_node_id ( ) ) ) ;
564
543
} ,
565
- MonitorUpdateId { contents : UpdateOrigin :: ChainSync ( completed_update_id) } => {
566
- let monitor_has_pending_updates =
567
- monitor_data. has_pending_chainsync_updates ( & pending_monitor_updates) ;
568
- log_debug ! ( self . logger, "Completed chain sync monitor update {} for channel with funding outpoint {:?}, {}" ,
569
- completed_update_id,
570
- funding_txo,
571
- if monitor_has_pending_updates {
572
- "still have pending chain sync updates"
573
- } else {
574
- "all chain sync updates complete, releasing pending MonitorEvents"
575
- } ) ;
576
- if !monitor_has_pending_updates {
577
- monitor_data. last_chain_persist_height . store ( self . highest_chain_height . load ( Ordering :: Acquire ) , Ordering :: Release ) ;
578
- // The next time release_pending_monitor_events is called, any events for this
579
- // ChannelMonitor will be returned.
580
- }
581
- } ,
544
+ MonitorUpdateId { contents : UpdateOrigin :: ChainSync ( _) } => { } ,
582
545
}
583
546
self . event_notifier . notify ( ) ;
584
547
Ok ( ( ) )
@@ -833,7 +796,6 @@ where C::Target: chain::Filter,
833
796
entry. insert ( MonitorHolder {
834
797
monitor,
835
798
pending_monitor_updates : Mutex :: new ( pending_monitor_updates) ,
836
- last_chain_persist_height : AtomicUsize :: new ( self . highest_chain_height . load ( Ordering :: Acquire ) ) ,
837
799
} ) ;
838
800
Ok ( persist_res)
839
801
}
0 commit comments