Skip to content

Commit f9533d8

Browse files
committed
f add reasons why the constants
1 parent 6383a44 commit f9533d8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/routing/scoring.rs

+8
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,14 @@ impl HistoricalBucketRangeTracker {
455455
//
456456
// In total, this allows us to track data for the last 8,000 or so payments across a given
457457
// channel.
458+
//
459+
// These constants are a balance - we try to fit in 2 bytes per bucket to reduce overhead,
460+
// and need to balance having more bits in the decimal part (to ensure decay isn't too
461+
// step-wise) with having too few bits in the mantissa, causing us to not store very many
462+
// datapoints.
463+
//
464+
// The constants were picked experimentally, selecting a decay amount that restricts us
465+
// from overflowing buckets without having to cap them manually.
458466
debug_assert!(bucket < 8);
459467
if let Some(v) = self.buckets.get_mut(bucket as usize) {
460468
*v = v.saturating_add(32);

0 commit comments

Comments
 (0)