Rename Channel's latest-monitor-update fetch method for clarity
authorMatt Corallo <git@bluematt.me>
Tue, 20 Jun 2023 02:16:03 +0000 (02:16 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 23 Jun 2023 19:25:40 +0000 (19:25 +0000)
`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`.

lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs

index 2ff6da8011eef6254a0351220562c5b112cf86c6..4745ac80eb57651579fcbe08868232047b560bf7 100644 (file)
@@ -4404,7 +4404,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                (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
        }
index c7c16e077a2c42026838c828ff128a68baa74a96..f38c6c13da54e6dde3ba09e98ea527a712a99376 100644 (file)
@@ -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.");