Skip to content

Commit bcc1d38

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.
1 parent c418034 commit bcc1d38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13246,7 +13246,9 @@ where
1324613246
})
1324713247
.position(|retain_scid| retain_scid)
1324813248
})
13249-
.unwrap_or(0);
13249+
// `position` above will also return `None` if we have historical scids but they all
13250+
// need to be removed, so `end` should point to the last index in such cases.
13251+
.unwrap_or(self.context.historical_scids.len());
1325013252

1325113253
// Drains the oldest historical SCIDs until reaching one without
1325213254
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.

0 commit comments

Comments
 (0)