Skip to content

Commit 91bae8d

Browse files
f - Scope update_maps_on_chan_removal
1 parent 1f01103 commit 91bae8d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,20 +1271,22 @@ macro_rules! update_maps_on_chan_removal {
12711271
let mut id_to_peer = $self.id_to_peer.lock().unwrap();
12721272
id_to_peer.remove(&$channel.channel_id());
12731273
}
1274-
let mut short_to_chan_info = $self.short_to_chan_info.write().unwrap();
1275-
if let Some(short_id) = $channel.get_short_channel_id() {
1276-
short_to_chan_info.remove(&short_id);
1277-
} else {
1278-
// If the channel was never confirmed on-chain prior to its closure, remove the
1279-
// outbound SCID alias we used for it from the collision-prevention set. While we
1280-
// generally want to avoid ever re-using an outbound SCID alias across all channels, we
1281-
// also don't want a counterparty to be able to trivially cause a memory leak by simply
1282-
// opening a million channels with us which are closed before we ever reach the funding
1283-
// stage.
1284-
let alias_removed = $self.outbound_scid_aliases.lock().unwrap().remove(&$channel.outbound_scid_alias());
1285-
debug_assert!(alias_removed);
1286-
}
1287-
short_to_chan_info.remove(&$channel.outbound_scid_alias());
1274+
{
1275+
let mut short_to_chan_info = $self.short_to_chan_info.write().unwrap();
1276+
if let Some(short_id) = $channel.get_short_channel_id() {
1277+
short_to_chan_info.remove(&short_id);
1278+
} else {
1279+
// If the channel was never confirmed on-chain prior to its closure, remove the
1280+
// outbound SCID alias we used for it from the collision-prevention set. While we
1281+
// generally want to avoid ever re-using an outbound SCID alias across all channels, we
1282+
// also don't want a counterparty to be able to trivially cause a memory leak by simply
1283+
// opening a million channels with us which are closed before we ever reach the funding
1284+
// stage.
1285+
let alias_removed = $self.outbound_scid_aliases.lock().unwrap().remove(&$channel.outbound_scid_alias());
1286+
debug_assert!(alias_removed);
1287+
}
1288+
short_to_chan_info.remove(&$channel.outbound_scid_alias());
1289+
}
12881290
}
12891291
}
12901292

0 commit comments

Comments
 (0)