Use saturating_add when adding inflight HTLCs values

Previously this calculation could overflow, leading to panicking in `debug`.
This commit is contained in:
Elias Rohrer 2023-09-14 14:14:03 +02:00
parent 7b4fb9da88
commit 391da3f3b2
No known key found for this signature in database
GPG key ID: 36153082BDF676FD

View file

@ -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
};