Skip to content

Commit

Permalink
f always insert a latest_update_id even if the chan is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Nov 13, 2024
1 parent 0bf2975 commit 4156259
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12574,11 +12574,21 @@ where
}

for (funding_txo, monitor) in args.channel_monitors.iter() {
if monitor.offchain_closed() {
// We already appled a ChannelForceClosed update.
continue;
}
if !funding_txo_set.contains(funding_txo) {
if let Some(counterparty_node_id) = monitor.get_counterparty_node_id() {
per_peer_state.entry(counterparty_node_id)
.or_insert_with(|| Mutex::new(empty_peer_state()))
.lock().unwrap()
.closed_channel_monitor_update_ids.entry(monitor.channel_id())
.and_modify(|v| *v = cmp::max(monitor.get_latest_update_id(), *v))
.or_insert(monitor.get_latest_update_id());
}

if monitor.offchain_closed() {
// We already appled a ChannelForceClosed update.
continue;
}

let logger = WithChannelMonitor::from(&args.logger, monitor, None);
let channel_id = monitor.channel_id();
log_info!(logger, "Queueing monitor update to ensure missing channel {} is force closed",
Expand All @@ -12597,13 +12607,6 @@ where
update: monitor_update,
};
close_background_events.push(update);

per_peer_state.entry(counterparty_node_id)
.or_insert_with(|| Mutex::new(empty_peer_state()))
.lock().unwrap()
.closed_channel_monitor_update_ids.entry(monitor.channel_id())
.and_modify(|v| *v = cmp::max(monitor.get_latest_update_id(), *v))
.or_insert(monitor.get_latest_update_id());
} else {
// This is a fairly old `ChannelMonitor` that hasn't seen an update to its
// off-chain state since LDK 0.0.118 (as in LDK 0.0.119 any off-chain
Expand Down

0 comments on commit 4156259

Please sign in to comment.