Skip to content

Commit

Permalink
make addl float
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Dec 18, 2024
1 parent b5b8b89 commit a29ec21
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub static NO_DATA_PENALTY: core::sync::atomic::AtomicU64 = core::sync::atomic::
/// lolz
pub static POW: core::sync::atomic::AtomicU8 = core::sync::atomic::AtomicU8::new(3);
/// lulz
pub static ADDL: core::sync::atomic::AtomicU8 = core::sync::atomic::AtomicU8::new(10);
pub static ADDL: core::sync::atomic::AtomicU64 = core::sync::atomic::AtomicU8::new(unsafe { core::mem::transmute(0.0f64) });
/// trololol
pub static HIST_DECAY: core::sync::atomic::AtomicU64 = core::sync::atomic::AtomicU64::new(2047);
/// loltastic
Expand Down Expand Up @@ -1198,7 +1198,7 @@ let pow = POW.load(core::sync::atomic::Ordering::Acquire);
(max_liquidity_msat - amount_msat,
(max_liquidity_msat - min_liquidity_msat).saturating_add(1))
} else {
let addl = ADDL.load(core::sync::atomic::Ordering::Acquire);
let addl: f64 = unsafe { core::mem::transmute(ADDL.load(core::sync::atomic::Ordering::Acquire)) };
let capacity = capacity_msat as f64;
let min = (min_liquidity_msat as f64) / capacity;
let max = (max_liquidity_msat as f64) / capacity;
Expand All @@ -1215,14 +1215,14 @@ let addl = ADDL.load(core::sync::atomic::Ordering::Acquire);
// that we don't bother to normalize the CDF to total to 1, as it will come out in the
// division of num / den.
let (max_pow, amt_pow, min_pow) = three_f64_pow_5(max - 0.5, amount - 0.5, min - 0.5);
let (num, den) = if addl == 0 {
let (num, den) = if addl == 0.0 {
let num = max_pow - amt_pow;
let den = max_pow - min_pow;
(num, den)
} else {
let max_v = max_pow + (addl as f64) / 100.0 * (max - 0.5);
let amt_v = amt_pow + (addl as f64) / 100.0 * (amount - 0.5);
let min_v = min_pow + (addl as f64) / 100.0 * (min - 0.5);
let max_v = max_pow + addl / 100.0 * (max - 0.5);
let amt_v = amt_pow + addl / 100.0 * (amount - 0.5);
let min_v = min_pow + addl / 100.0 * (min - 0.5);
let num = max_v - amt_v;
let den = max_v - min_v;
(num, den)
Expand Down

0 comments on commit a29ec21

Please sign in to comment.