@@ -363,8 +363,9 @@ where C::Target: chain::Filter,
363
363
let mut txn_outputs;
364
364
{
365
365
txn_outputs = process ( monitor, txdata) ;
366
+ let chain_sync_update_id = self . sync_persistence_id . get_increment ( ) ;
366
367
let update_id = MonitorUpdateId {
367
- contents : UpdateOrigin :: ChainSync ( self . sync_persistence_id . get_increment ( ) ) ,
368
+ contents : UpdateOrigin :: ChainSync ( chain_sync_update_id ) ,
368
369
} ;
369
370
let mut pending_monitor_updates = monitor_state. pending_monitor_updates . lock ( ) . unwrap ( ) ;
370
371
if let Some ( height) = best_height {
@@ -376,10 +377,16 @@ where C::Target: chain::Filter,
376
377
}
377
378
}
378
379
379
- log_trace ! ( logger, "Syncing Channel Monitor for channel {}" , log_funding_info!( monitor) ) ;
380
+ log_trace ! ( logger, "Syncing Channel Monitor for channel {} for block-data update_id {}" ,
381
+ log_funding_info!( monitor) ,
382
+ chain_sync_update_id
383
+ ) ;
380
384
match self . persister . update_persisted_channel ( * funding_outpoint, None , monitor, update_id) {
381
385
ChannelMonitorUpdateStatus :: Completed =>
382
- log_trace ! ( logger, "Finished syncing Channel Monitor for channel {}" , log_funding_info!( monitor) ) ,
386
+ log_trace ! ( logger, "Finished syncing Channel Monitor for channel {} for block-data update_id {}" ,
387
+ log_funding_info!( monitor) ,
388
+ chain_sync_update_id
389
+ ) ,
383
390
ChannelMonitorUpdateStatus :: InProgress => {
384
391
log_debug ! ( logger, "Channel Monitor sync for channel {} in progress, holding events until completion!" , log_funding_info!( monitor) ) ;
385
392
pending_monitor_updates. push ( update_id) ;
@@ -526,7 +533,7 @@ where C::Target: chain::Filter,
526
533
pending_monitor_updates. retain ( |update_id| * update_id != completed_update_id) ;
527
534
528
535
match completed_update_id {
529
- MonitorUpdateId { contents : UpdateOrigin :: OffChain ( _ ) } => {
536
+ MonitorUpdateId { contents : UpdateOrigin :: OffChain ( completed_update_id ) } => {
530
537
// Note that we only check for `UpdateOrigin::OffChain` failures here - if
531
538
// we're being told that a `UpdateOrigin::OffChain` monitor update completed,
532
539
// we only care about ensuring we don't tell the `ChannelManager` to restore
@@ -537,6 +544,14 @@ where C::Target: chain::Filter,
537
544
// `MonitorEvent`s from the monitor back to the `ChannelManager` until they
538
545
// complete.
539
546
let monitor_is_pending_updates = monitor_data. has_pending_offchain_updates ( & pending_monitor_updates) ;
547
+ log_debug ! ( self . logger, "Completed off-chain monitor update {} for channel with funding outpoint {:?}, {}" ,
548
+ completed_update_id,
549
+ funding_txo,
550
+ if monitor_is_pending_updates {
551
+ "still have pending off-chain updates"
552
+ } else {
553
+ "all off-chain updates complete, returning a MonitorEvent"
554
+ } ) ;
540
555
if monitor_is_pending_updates {
541
556
// If there are still monitor updates pending, we cannot yet construct a
542
557
// Completed event.
@@ -547,8 +562,18 @@ where C::Target: chain::Filter,
547
562
monitor_update_id: monitor_data. monitor. get_latest_update_id( ) ,
548
563
} ] , monitor_data. monitor . get_counterparty_node_id ( ) ) ) ;
549
564
} ,
550
- MonitorUpdateId { contents : UpdateOrigin :: ChainSync ( _) } => {
551
- if !monitor_data. has_pending_chainsync_updates ( & pending_monitor_updates) {
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 {
552
577
monitor_data. last_chain_persist_height . store ( self . highest_chain_height . load ( Ordering :: Acquire ) , Ordering :: Release ) ;
553
578
// The next time release_pending_monitor_events is called, any events for this
554
579
// ChannelMonitor will be returned.
@@ -771,7 +796,7 @@ where C::Target: chain::Filter,
771
796
Some ( monitor_state) => {
772
797
let monitor = & monitor_state. monitor ;
773
798
let logger = WithChannelMonitor :: from ( & self . logger , & monitor) ;
774
- log_trace ! ( logger, "Updating ChannelMonitor for channel {}" , log_funding_info!( monitor) ) ;
799
+ log_trace ! ( logger, "Updating ChannelMonitor to id {} for channel {}" , update . update_id , log_funding_info!( monitor) ) ;
775
800
let update_res = monitor. update_monitor ( update, & self . broadcaster , & self . fee_estimator , & self . logger ) ;
776
801
777
802
let update_id = MonitorUpdateId :: from_monitor_update ( update) ;
@@ -790,10 +815,18 @@ where C::Target: chain::Filter,
790
815
match persist_res {
791
816
ChannelMonitorUpdateStatus :: InProgress => {
792
817
pending_monitor_updates. push ( update_id) ;
793
- log_debug ! ( logger, "Persistence of ChannelMonitorUpdate for channel {} in progress" , log_funding_info!( monitor) ) ;
818
+ log_debug ! ( logger,
819
+ "Persistence of ChannelMonitorUpdate id {:?} for channel {} in progress" ,
820
+ update_id,
821
+ log_funding_info!( monitor)
822
+ ) ;
794
823
} ,
795
824
ChannelMonitorUpdateStatus :: Completed => {
796
- log_debug ! ( logger, "Persistence of ChannelMonitorUpdate for channel {} completed" , log_funding_info!( monitor) ) ;
825
+ log_debug ! ( logger,
826
+ "Persistence of ChannelMonitorUpdate id {:?} for channel {} completed" ,
827
+ update_id,
828
+ log_funding_info!( monitor)
829
+ ) ;
797
830
} ,
798
831
ChannelMonitorUpdateStatus :: UnrecoverableError => {
799
832
// Take the monitors lock for writing so that we poison it and any future
0 commit comments