@@ -363,8 +363,9 @@ where C::Target: chain::Filter,
363363 let mut txn_outputs;
364364 {
365365 txn_outputs = process ( monitor, txdata) ;
366+ let chain_sync_update_id = self . sync_persistence_id . get_increment ( ) ;
366367 let update_id = MonitorUpdateId {
367- contents : UpdateOrigin :: ChainSync ( self . sync_persistence_id . get_increment ( ) ) ,
368+ contents : UpdateOrigin :: ChainSync ( chain_sync_update_id ) ,
368369 } ;
369370 let mut pending_monitor_updates = monitor_state. pending_monitor_updates . lock ( ) . unwrap ( ) ;
370371 if let Some ( height) = best_height {
@@ -376,10 +377,16 @@ where C::Target: chain::Filter,
376377 }
377378 }
378379
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+ ) ;
380384 match self . persister . update_persisted_channel ( * funding_outpoint, None , monitor, update_id) {
381385 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+ ) ,
383390 ChannelMonitorUpdateStatus :: InProgress => {
384391 log_debug ! ( logger, "Channel Monitor sync for channel {} in progress, holding events until completion!" , log_funding_info!( monitor) ) ;
385392 pending_monitor_updates. push ( update_id) ;
@@ -526,7 +533,7 @@ where C::Target: chain::Filter,
526533 pending_monitor_updates. retain ( |update_id| * update_id != completed_update_id) ;
527534
528535 match completed_update_id {
529- MonitorUpdateId { contents : UpdateOrigin :: OffChain ( _ ) } => {
536+ MonitorUpdateId { contents : UpdateOrigin :: OffChain ( completed_update_id ) } => {
530537 // Note that we only check for `UpdateOrigin::OffChain` failures here - if
531538 // we're being told that a `UpdateOrigin::OffChain` monitor update completed,
532539 // we only care about ensuring we don't tell the `ChannelManager` to restore
@@ -537,6 +544,14 @@ where C::Target: chain::Filter,
537544 // `MonitorEvent`s from the monitor back to the `ChannelManager` until they
538545 // complete.
539546 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+ } ) ;
540555 if monitor_is_pending_updates {
541556 // If there are still monitor updates pending, we cannot yet construct a
542557 // Completed event.
@@ -547,8 +562,18 @@ where C::Target: chain::Filter,
547562 monitor_update_id: monitor_data. monitor. get_latest_update_id( ) ,
548563 } ] , monitor_data. monitor . get_counterparty_node_id ( ) ) ) ;
549564 } ,
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 {
552577 monitor_data. last_chain_persist_height . store ( self . highest_chain_height . load ( Ordering :: Acquire ) , Ordering :: Release ) ;
553578 // The next time release_pending_monitor_events is called, any events for this
554579 // ChannelMonitor will be returned.
@@ -771,7 +796,7 @@ where C::Target: chain::Filter,
771796 Some ( monitor_state) => {
772797 let monitor = & monitor_state. monitor ;
773798 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) ) ;
775800 let update_res = monitor. update_monitor ( update, & self . broadcaster , & self . fee_estimator , & self . logger ) ;
776801
777802 let update_id = MonitorUpdateId :: from_monitor_update ( update) ;
@@ -790,10 +815,18 @@ where C::Target: chain::Filter,
790815 match persist_res {
791816 ChannelMonitorUpdateStatus :: InProgress => {
792817 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+ ) ;
794823 } ,
795824 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+ ) ;
797830 } ,
798831 ChannelMonitorUpdateStatus :: UnrecoverableError => {
799832 // Take the monitors lock for writing so that we poison it and any future
0 commit comments