Skip to content

Commit c182b27

Browse files
committed
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`.
1 parent 225dcbb commit c182b27

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lightning/src/ln/channel.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4395,7 +4395,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
43954395
(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32) != 0
43964396
}
43974397

4398-
pub fn get_latest_complete_monitor_update_id(&self) -> u64 {
4398+
/// Gets the latest [`ChannelMonitorUpdate`] ID which has been released and is in-flight.
4399+
pub fn get_latest_unblocked_monitor_update_id(&self) -> u64 {
43994400
if self.context.pending_monitor_updates.is_empty() { return self.context.get_latest_monitor_update_id(); }
44004401
self.context.pending_monitor_updates[0].update.update_id - 1
44014402
}

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8342,12 +8342,12 @@ where
83428342
peer_state.in_flight_monitor_updates.insert(funding_txo, chan_in_flight_upds);
83438343
}
83448344
}
8345-
if chan.get_latest_complete_monitor_update_id() > max_in_flight_update_id {
8345+
if chan.get_latest_unblocked_monitor_update_id() > max_in_flight_update_id {
83468346
// If the channel is ahead of the monitor, return InvalidValue:
83478347
log_error!(args.logger, "A ChannelMonitor is stale compared to the current ChannelManager! This indicates a potentially-critical violation of the chain::Watch API!");
83488348
log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} with update_id through {} in-flight",
83498349
log_bytes!(chan.context.channel_id()), monitor.get_latest_update_id(), max_in_flight_update_id);
8350-
log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_complete_monitor_update_id());
8350+
log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_unblocked_monitor_update_id());
83518351
log_error!(args.logger, " The chain::Watch API *requires* that monitors are persisted durably before returning,");
83528352
log_error!(args.logger, " client applications must ensure that ChannelMonitor data is always available and the latest to avoid funds loss!");
83538353
log_error!(args.logger, " Without the latest ChannelMonitor we cannot continue without risking funds.");

0 commit comments

Comments
 (0)