Skip to content

Commit 19bf5ee

Browse files
committed
When removing PeerState check for in-flight mon updates deeply
When deciding if we should remove a `PeerState` entry we want to ensure we don't remove if there are pending updates in `in_flight_monitor_updates`. Previously this was done with a simple `in_flight_monitor_updates.is_empty()`, however this can prevent removal of `PeerState` entries if a channel had an update at some point (leaving an entry in the map) but the update was ultimately completed. Instead, we need to iterate over the entries in `in_flight_monitor_updates` and decline to remove `PeerState`s only if there is an entry for a pending update still in-flight.
1 parent aba57bb commit 19bf5ee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,11 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
13321332
if require_disconnected && self.is_connected {
13331333
return false
13341334
}
1335+
for (_, updates) in self.in_flight_monitor_updates.iter() {
1336+
if !updates.is_empty() {
1337+
return false;
1338+
}
1339+
}
13351340
!self.channel_by_id.iter().any(|(_, phase)|
13361341
match phase {
13371342
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
@@ -1341,7 +1346,6 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
13411346
}
13421347
)
13431348
&& self.monitor_update_blocked_actions.is_empty()
1344-
&& self.in_flight_monitor_updates.is_empty()
13451349
&& self.closed_channel_monitor_update_ids.is_empty()
13461350
}
13471351

0 commit comments

Comments
 (0)