From: Matt Corallo Date: Tue, 20 Jun 2023 02:16:03 +0000 (+0000) Subject: Rename Channel's latest-monitor-update fetch method for clarity X-Git-Tag: v0.0.116-alpha1~3^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=7884e687d2e6cae1da5bbc514546c284359f703c;p=rust-lightning Rename Channel's latest-monitor-update fetch method for clarity `Channel::get_latest_complete_monitor_update_id` no longer refers to complete updates, but rather ones which were passed to the `ChannelManager` and which the `CHannel` no longer knows about. Thus, we rename it `get_latest_unblocked_monitor_update_id`. --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 2ff6da801..4745ac80e 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -4404,7 +4404,8 @@ impl Channel { (self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32) != 0 } - pub fn get_latest_complete_monitor_update_id(&self) -> u64 { + /// Gets the latest [`ChannelMonitorUpdate`] ID which has been released and is in-flight. + pub fn get_latest_unblocked_monitor_update_id(&self) -> u64 { if self.context.pending_monitor_updates.is_empty() { return self.context.get_latest_monitor_update_id(); } self.context.pending_monitor_updates[0].update.update_id - 1 } diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index c7c16e077..f38c6c13d 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -8441,12 +8441,12 @@ where funding_txo, monitor, peer_state, "")); } } - if chan.get_latest_complete_monitor_update_id() > max_in_flight_update_id { + if chan.get_latest_unblocked_monitor_update_id() > max_in_flight_update_id { // If the channel is ahead of the monitor, return InvalidValue: log_error!(args.logger, "A ChannelMonitor is stale compared to the current ChannelManager! This indicates a potentially-critical violation of the chain::Watch API!"); log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} with update_id through {} in-flight", log_bytes!(chan.context.channel_id()), monitor.get_latest_update_id(), max_in_flight_update_id); - log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_complete_monitor_update_id()); + log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_unblocked_monitor_update_id()); log_error!(args.logger, " The chain::Watch API *requires* that monitors are persisted durably before returning,"); log_error!(args.logger, " client applications must ensure that ChannelMonitor data is always available and the latest to avoid funds loss!"); log_error!(args.logger, " Without the latest ChannelMonitor we cannot continue without risking funds.");