Skip to content

Commit a764048

Browse files
committed
f simplify substantially
1 parent cca68c3 commit a764048

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lightning/src/routing/scoring.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,11 @@ impl HistoricalMinMaxBuckets<'_> {
602602
let required_decays = now.duration_since(last_updated).as_secs()
603603
.checked_div(half_life.as_secs())
604604
.map_or(u32::max_value(), |decays| cmp::min(decays, u32::max_value() as u64) as u32);
605-
let mut min_buckets = [0; 8];
606-
for (idx, bucket) in self.min_liquidity_offset_history.buckets.iter().enumerate() {
607-
min_buckets[idx] = (*bucket).checked_shr(required_decays).unwrap_or(0);
608-
}
609-
let mut max_buckets = [0; 8];
610-
for (idx, bucket) in self.max_liquidity_offset_history.buckets.iter().enumerate() {
611-
max_buckets[idx] = (*bucket).checked_shr(required_decays).unwrap_or(0);
612-
}
613-
(min_buckets, max_buckets, required_decays)
605+
let mut min_buckets = *self.min_liquidity_offset_history;
606+
min_buckets.time_decay_data(required_decays);
607+
let mut max_buckets = *self.max_liquidity_offset_history;
608+
max_buckets.time_decay_data(required_decays);
609+
(min_buckets.buckets, max_buckets.buckets, required_decays)
614610
}
615611

616612
#[inline]

0 commit comments

Comments
 (0)