We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3413ede commit 07cd143Copy full SHA for 07cd143
lightning/src/routing/scorer.rs
@@ -170,8 +170,12 @@ impl routing::Score for Scorer {
170
171
#[cfg(not(feature = "no-std"))]
172
fn decay_from(penalty_msat: u64, last_failure: &SystemTime, half_life: Duration) -> u64 {
173
- let decays = last_failure.elapsed().ok().map_or(0, |elapsed| {
174
- elapsed.as_secs() / half_life.as_secs()
175
- });
176
- penalty_msat >> decays
+ let decays = match last_failure.elapsed().ok() {
+ Some(elapsed) => elapsed.as_secs().checked_div(half_life.as_secs()),
+ None => Some(0),
+ };
177
+ match decays {
178
+ Some(decays) => penalty_msat >> decays,
179
+ None => 0,
180
+ }
181
}
0 commit comments