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 82771bb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12574,10 +12574,20 @@ where
}

for (funding_txo, monitor) in args.channel_monitors.iter() {
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;
}

if !funding_txo_set.contains(funding_txo) {
let logger = WithChannelMonitor::from(&args.logger, monitor, None);
let channel_id = monitor.channel_id();
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 82771bb

Please sign in to comment.