Skip to content

Commit f2ada1a

Browse files
wpaulinoTheBlueMatt
authored andcommitted
Fix legacy SCID pruning
We relied on `position` giving us the last index we need to prune, but this may return `None` when all known legacy SCIDs need to be pruned. In such cases, we ended up not pruning any of the legacy SCIDs at all. Rewritten by: Matt Corallo <git@bluematt.me>
1 parent c418034 commit f2ada1a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13233,18 +13233,18 @@ where
1323313233
let end = self
1323413234
.funding
1323513235
.get_short_channel_id()
13236-
.and_then(|current_scid| {
13236+
.map(|current_scid| {
1323713237
let historical_scids = &self.context.historical_scids;
1323813238
historical_scids
1323913239
.iter()
1324013240
.zip(historical_scids.iter().skip(1).chain(core::iter::once(&current_scid)))
13241-
.map(|(_, next_scid)| {
13242-
let funding_height = block_from_scid(*next_scid);
13243-
let retain_scid =
13244-
funding_height + CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY - 1 > height;
13245-
retain_scid
13241+
.filter(|(_, next_scid)| {
13242+
let funding_height = block_from_scid(**next_scid);
13243+
let drop_scid =
13244+
funding_height + CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY - 1 <= height;
13245+
drop_scid
1324613246
})
13247-
.position(|retain_scid| retain_scid)
13247+
.count()
1324813248
})
1324913249
.unwrap_or(0);
1325013250

0 commit comments

Comments
 (0)