Skip to content

Commit 73670e1

Browse files
committed
Debug-log monitor update completions in ChainMonitor
When a `ChannelMonitor[Update]` persistence completes, we rely on logging in `ChannelManager` to hear about it. However, this won't happen at all if there's still pending updates as no `MonitorEvent` will be generated. Thus, here, we add logging directly in `ChainMonitor`, ensuring we can deduce when individual updates completed from debug logs.
1 parent 10480f0 commit 73670e1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,13 @@ where C::Target: chain::Filter,
537537
// `MonitorEvent`s from the monitor back to the `ChannelManager` until they
538538
// complete.
539539
let monitor_is_pending_updates = monitor_data.has_pending_offchain_updates(&pending_monitor_updates);
540+
log_debug!(self.logger, "Completed off-chain monitor update for channel with funding outpoint {:?}, {}",
541+
funding_txo,
542+
if monitor_is_pending_updates {
543+
"still have pending off-chain updates"
544+
} else {
545+
"all off-chain updates complete, returning a MonitorEvent"
546+
});
540547
if monitor_is_pending_updates {
541548
// If there are still monitor updates pending, we cannot yet construct a
542549
// Completed event.
@@ -548,7 +555,16 @@ where C::Target: chain::Filter,
548555
}], monitor_data.monitor.get_counterparty_node_id()));
549556
},
550557
MonitorUpdateId { contents: UpdateOrigin::ChainSync(_) } => {
551-
if !monitor_data.has_pending_chainsync_updates(&pending_monitor_updates) {
558+
let monitor_has_pending_updates =
559+
monitor_data.has_pending_chainsync_updates(&pending_monitor_updates);
560+
log_debug!(self.logger, "Completed chain sync monitor update for channel with funding outpoint {:?}, {}",
561+
funding_txo,
562+
if monitor_has_pending_updates {
563+
"still have pending chain sync updates"
564+
} else {
565+
"all chain sync updates complete, releasing pending MonitorEvents"
566+
});
567+
if !monitor_has_pending_updates {
552568
monitor_data.last_chain_persist_height.store(self.highest_chain_height.load(Ordering::Acquire), Ordering::Release);
553569
// The next time release_pending_monitor_events is called, any events for this
554570
// ChannelMonitor will be returned.

0 commit comments

Comments
 (0)