Track history of where channel liquidities have been in the past
authorMatt Corallo <git@bluematt.me>
Tue, 19 Jul 2022 22:37:16 +0000 (22:37 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 6 Oct 2022 21:10:23 +0000 (21:10 +0000)
commitc5eab6e11f050c7f049b3bfaac35d35bcf5b751a
tree81ee2e219b3e3570aaa742623028374bc18b3edf
parentb84b53a14c37a926664dd767d78b3c5a34a871ab
Track history of where channel liquidities have been in the past

This introduces two new fields to the `ChannelLiquidity` struct -
`min_liquidity_offset_history` and `max_liquidity_offset_history`,
both an array of 8 `u16`s. Each entry represents the proportion of
time that we spent with the min or max liquidity offset in the
given 1/8th of the channel's liquidity range. ie the first bucket
in `min_liquidity_offset_history` represents the proportion of time
we've thought the channel's minimum liquidity is lower than 1/8th's
the channel's capacity.

Each bucket is stored, effectively, as a fixed-point number with
5 bits for the fractional part, which is incremented by one (ie 32)
each time we update our liquidity estimates and decide our
estimates are in that bucket. We then decay each bucket by
2047/2048.

Thus, memory of a payment sticks around for more than 8,000
data points, though the majority of that memory decays after 1,387
data points.
lightning/src/routing/scoring.rs
lightning/src/util/ser.rs