@@ -368,8 +368,9 @@ where C::Target: chain::Filter,
368
368
let mut txn_outputs;
369
369
{
370
370
txn_outputs = process ( monitor, txdata) ;
371
+ let chain_sync_update_id = self . sync_persistence_id . get_increment ( ) ;
371
372
let update_id = MonitorUpdateId {
372
- contents : UpdateOrigin :: ChainSync ( self . sync_persistence_id . get_increment ( ) ) ,
373
+ contents : UpdateOrigin :: ChainSync ( chain_sync_update_id ) ,
373
374
} ;
374
375
let mut pending_monitor_updates = monitor_state. pending_monitor_updates . lock ( ) . unwrap ( ) ;
375
376
if let Some ( height) = best_height {
@@ -381,10 +382,16 @@ where C::Target: chain::Filter,
381
382
}
382
383
}
383
384
384
- log_trace ! ( logger, "Syncing Channel Monitor for channel {}" , log_funding_info!( monitor) ) ;
385
+ log_trace ! ( logger, "Syncing Channel Monitor for channel {} for block-data update_id {}" ,
386
+ log_funding_info!( monitor) ,
387
+ chain_sync_update_id
388
+ ) ;
385
389
match self . persister . update_persisted_channel ( * funding_outpoint, None , monitor, update_id) {
386
390
ChannelMonitorUpdateStatus :: Completed =>
387
- log_trace ! ( logger, "Finished syncing Channel Monitor for channel {}" , log_funding_info!( monitor) ) ,
391
+ log_trace ! ( logger, "Finished syncing Channel Monitor for channel {} for block-data update_id {}" ,
392
+ log_funding_info!( monitor) ,
393
+ chain_sync_update_id
394
+ ) ,
388
395
ChannelMonitorUpdateStatus :: InProgress => {
389
396
log_debug ! ( logger, "Channel Monitor sync for channel {} in progress, holding events until completion!" , log_funding_info!( monitor) ) ;
390
397
pending_monitor_updates. push ( update_id) ;
@@ -534,7 +541,7 @@ where C::Target: chain::Filter,
534
541
pending_monitor_updates. retain ( |update_id| * update_id != completed_update_id) ;
535
542
536
543
match completed_update_id {
537
- MonitorUpdateId { contents : UpdateOrigin :: OffChain ( _ ) } => {
544
+ MonitorUpdateId { contents : UpdateOrigin :: OffChain ( completed_update_id ) } => {
538
545
// Note that we only check for `UpdateOrigin::OffChain` failures here - if
539
546
// we're being told that a `UpdateOrigin::OffChain` monitor update completed,
540
547
// we only care about ensuring we don't tell the `ChannelManager` to restore
@@ -545,6 +552,14 @@ where C::Target: chain::Filter,
545
552
// `MonitorEvent`s from the monitor back to the `ChannelManager` until they
546
553
// complete.
547
554
let monitor_is_pending_updates = monitor_data. has_pending_offchain_updates ( & pending_monitor_updates) ;
555
+ log_debug ! ( self . logger, "Completed off-chain monitor update {} for channel with funding outpoint {:?}, {}" ,
556
+ completed_update_id,
557
+ funding_txo,
558
+ if monitor_is_pending_updates {
559
+ "still have pending off-chain updates"
560
+ } else {
561
+ "all off-chain updates complete, returning a MonitorEvent"
562
+ } ) ;
548
563
if monitor_is_pending_updates {
549
564
// If there are still monitor updates pending, we cannot yet construct a
550
565
// Completed event.
@@ -556,8 +571,18 @@ where C::Target: chain::Filter,
556
571
monitor_update_id: monitor_data. monitor. get_latest_update_id( ) ,
557
572
} ] , monitor_data. monitor . get_counterparty_node_id ( ) ) ) ;
558
573
} ,
559
- MonitorUpdateId { contents : UpdateOrigin :: ChainSync ( _) } => {
560
- if !monitor_data. has_pending_chainsync_updates ( & pending_monitor_updates) {
574
+ MonitorUpdateId { contents : UpdateOrigin :: ChainSync ( completed_update_id) } => {
575
+ let monitor_has_pending_updates =
576
+ monitor_data. has_pending_chainsync_updates ( & pending_monitor_updates) ;
577
+ log_debug ! ( self . logger, "Completed chain sync monitor update {} for channel with funding outpoint {:?}, {}" ,
578
+ completed_update_id,
579
+ funding_txo,
580
+ if monitor_has_pending_updates {
581
+ "still have pending chain sync updates"
582
+ } else {
583
+ "all chain sync updates complete, releasing pending MonitorEvents"
584
+ } ) ;
585
+ if !monitor_has_pending_updates {
561
586
monitor_data. last_chain_persist_height . store ( self . highest_chain_height . load ( Ordering :: Acquire ) , Ordering :: Release ) ;
562
587
// The next time release_pending_monitor_events is called, any events for this
563
588
// ChannelMonitor will be returned.
@@ -844,7 +869,7 @@ where C::Target: chain::Filter,
844
869
Some ( monitor_state) => {
845
870
let monitor = & monitor_state. monitor ;
846
871
let logger = WithChannelMonitor :: from ( & self . logger , & monitor) ;
847
- log_trace ! ( logger, "Updating ChannelMonitor for channel {}" , log_funding_info!( monitor) ) ;
872
+ log_trace ! ( logger, "Updating ChannelMonitor to id {} for channel {}" , update . update_id , log_funding_info!( monitor) ) ;
848
873
let update_res = monitor. update_monitor ( update, & self . broadcaster , & self . fee_estimator , & self . logger ) ;
849
874
850
875
let update_id = MonitorUpdateId :: from_monitor_update ( update) ;
@@ -863,10 +888,18 @@ where C::Target: chain::Filter,
863
888
match persist_res {
864
889
ChannelMonitorUpdateStatus :: InProgress => {
865
890
pending_monitor_updates. push ( update_id) ;
866
- log_debug ! ( logger, "Persistence of ChannelMonitorUpdate for channel {} in progress" , log_funding_info!( monitor) ) ;
891
+ log_debug ! ( logger,
892
+ "Persistence of ChannelMonitorUpdate id {:?} for channel {} in progress" ,
893
+ update_id,
894
+ log_funding_info!( monitor)
895
+ ) ;
867
896
} ,
868
897
ChannelMonitorUpdateStatus :: Completed => {
869
- log_debug ! ( logger, "Persistence of ChannelMonitorUpdate for channel {} completed" , log_funding_info!( monitor) ) ;
898
+ log_debug ! ( logger,
899
+ "Persistence of ChannelMonitorUpdate id {:?} for channel {} completed" ,
900
+ update_id,
901
+ log_funding_info!( monitor)
902
+ ) ;
870
903
} ,
871
904
ChannelMonitorUpdateStatus :: UnrecoverableError => {
872
905
// Take the monitors lock for writing so that we poison it and any future
0 commit comments