Skip to content

Commit

Permalink
f more decay docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Aug 30, 2022
1 parent 4775973 commit 29f2d2a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ impl HistoricalBucketRangeTracker {
}
}
}
fn decay_data(&mut self, half_lives: u32) {
/// Decay all buckets by the given number of half-lives. Used to more aggressively remove old
/// datapoints as we receive newer information.
fn time_decay_data(&mut self, half_lives: u32) {
for e in self.buckets.iter_mut() {
*e = e.checked_shr(half_lives).unwrap_or(0);
}
Expand Down Expand Up @@ -948,8 +950,8 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
let half_lives = self.now.duration_since(*self.last_updated).as_secs()
.checked_div(self.params.historical_no_updates_half_life.as_secs())
.map(|v| v.try_into().unwrap_or(u32::max_value())).unwrap_or(u32::max_value());
self.min_liquidity_offset_history.decay_data(half_lives);
self.max_liquidity_offset_history.decay_data(half_lives);
self.min_liquidity_offset_history.time_decay_data(half_lives);
self.max_liquidity_offset_history.time_decay_data(half_lives);

debug_assert!(*self.min_liquidity_offset_msat <= self.capacity_msat);
self.min_liquidity_offset_history.track_datapoint(
Expand Down

0 comments on commit 29f2d2a

Please sign in to comment.