Skip to content

Commit 3ae2a3c

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 b08a502 commit 3ae2a3c

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
@@ -4404,7 +4404,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
44044404
(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32) != 0
44054405
}
44064406

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

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8421,12 +8421,12 @@ where
84218421
peer_state.in_flight_monitor_updates.insert(funding_txo, chan_in_flight_upds);
84228422
}
84238423
}
8424-
if chan.get_latest_complete_monitor_update_id() > max_in_flight_update_id {
8424+
if chan.get_latest_unblocked_monitor_update_id() > max_in_flight_update_id {
84258425
// If the channel is ahead of the monitor, return InvalidValue:
84268426
log_error!(args.logger, "A ChannelMonitor is stale compared to the current ChannelManager! This indicates a potentially-critical violation of the chain::Watch API!");
84278427
log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} with update_id through {} in-flight",
84288428
log_bytes!(chan.context.channel_id()), monitor.get_latest_update_id(), max_in_flight_update_id);
8429-
log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_complete_monitor_update_id());
8429+
log_error!(args.logger, " but the ChannelManager is at update_id {}.", chan.get_latest_unblocked_monitor_update_id());
84308430
log_error!(args.logger, " The chain::Watch API *requires* that monitors are persisted durably before returning,");
84318431
log_error!(args.logger, " client applications must ensure that ChannelMonitor data is always available and the latest to avoid funds loss!");
84328432
log_error!(args.logger, " Without the latest ChannelMonitor we cannot continue without risking funds.");

0 commit comments

Comments
 (0)