- match completed_update_id {
- MonitorUpdateId { contents: UpdateOrigin::OffChain(completed_update_id) } => {
- // Note that we only check for `UpdateOrigin::OffChain` failures here - if
- // we're being told that a `UpdateOrigin::OffChain` monitor update completed,
- // we only care about ensuring we don't tell the `ChannelManager` to restore
- // the channel to normal operation until all `UpdateOrigin::OffChain` updates
- // complete.
- // If there's some `UpdateOrigin::ChainSync` update still pending that's okay
- // - we can still update our channel state, just as long as we don't return
- // `MonitorEvent`s from the monitor back to the `ChannelManager` until they
- // complete.
- let monitor_is_pending_updates = monitor_data.has_pending_offchain_updates(&pending_monitor_updates);
- log_debug!(self.logger, "Completed off-chain monitor update {} for channel with funding outpoint {:?}, {}",
- completed_update_id,
- funding_txo,
- if monitor_is_pending_updates {
- "still have pending off-chain updates"
- } else {
- "all off-chain updates complete, returning a MonitorEvent"
- });
- if monitor_is_pending_updates {
- // If there are still monitor updates pending, we cannot yet construct a
- // Completed event.
- return Ok(());
- }
- let channel_id = monitor_data.monitor.channel_id();
- self.pending_monitor_events.lock().unwrap().push((funding_txo, channel_id, vec![MonitorEvent::Completed {
- funding_txo, channel_id,
- monitor_update_id: monitor_data.monitor.get_latest_update_id(),
- }], monitor_data.monitor.get_counterparty_node_id()));
- },
- MonitorUpdateId { contents: UpdateOrigin::ChainSync(completed_update_id) } => {
- let monitor_has_pending_updates =
- monitor_data.has_pending_chainsync_updates(&pending_monitor_updates);
- log_debug!(self.logger, "Completed chain sync monitor update {} for channel with funding outpoint {:?}, {}",
- completed_update_id,
- funding_txo,
- if monitor_has_pending_updates {
- "still have pending chain sync updates"
- } else {
- "all chain sync updates complete, releasing pending MonitorEvents"
- });
- if !monitor_has_pending_updates {
- monitor_data.last_chain_persist_height.store(self.highest_chain_height.load(Ordering::Acquire), Ordering::Release);
- // The next time release_pending_monitor_events is called, any events for this
- // ChannelMonitor will be returned.
- }
- },
+ // Note that we only check for pending non-chainsync monitor updates and we don't track monitor
+ // updates resulting from chainsync in `pending_monitor_updates`.
+ let monitor_is_pending_updates = monitor_data.has_pending_updates(&pending_monitor_updates);
+ log_debug!(self.logger, "Completed off-chain monitor update {} for channel with funding outpoint {:?}, {}",
+ completed_update_id,
+ funding_txo,
+ if monitor_is_pending_updates {
+ "still have pending off-chain updates"
+ } else {
+ "all off-chain updates complete, returning a MonitorEvent"
+ });
+ if monitor_is_pending_updates {
+ // If there are still monitor updates pending, we cannot yet construct a
+ // Completed event.
+ return Ok(());