Skip to content

Commit

Permalink
Use saturating_add when adding inflight HTLCs values
Browse files Browse the repository at this point in the history
Previously this calculation could overflow, leading to panicking in `debug`.
  • Loading branch information
tnull committed Sep 19, 2023
1 parent 5035fa8 commit 50c9dba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'a, SP: Sized, Sc: 'a + ScoreLookUp<ScoreParams = SP>, S: Deref<Target = Sc
source, target, short_channel_id
) {
let usage = ChannelUsage {
inflight_htlc_msat: usage.inflight_htlc_msat + used_liquidity,
inflight_htlc_msat: usage.inflight_htlc_msat.saturating_add(used_liquidity),
..usage
};

Expand Down

0 comments on commit 50c9dba

Please sign in to comment.