Skip to content

Commit c22a032

Browse files
committed
Update last_datapoint_time even if we don't update bounds
When we see a failure or success and it doesn't result in a bounds update, we previously were'nt updating the `last_datapoint_time` field as we were updating it in the bounds-update logic. This is wrong for the purpose of the `probing_diversity_penalty` because the whole point is to avoid repeatedly probing the same channel, but because of this we'll probe the same channel again and again as long as we don't learn any new information from the probes which causes a bounds update.
1 parent 1923c1b commit c22a032

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightning/src/routing/scoring.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ DirectedChannelLiquidity<L, HT, T> {
15561556
chan_descr, existing_max_msat, amount_msat);
15571557
}
15581558
self.update_history_buckets(0, duration_since_epoch);
1559+
*self.last_datapoint_time = duration_since_epoch;
15591560
}
15601561

15611562
/// Adjusts the channel liquidity balance bounds when failing to route `amount_msat` downstream.
@@ -1571,6 +1572,7 @@ DirectedChannelLiquidity<L, HT, T> {
15711572
chan_descr, existing_min_msat, amount_msat);
15721573
}
15731574
self.update_history_buckets(0, duration_since_epoch);
1575+
*self.last_datapoint_time = duration_since_epoch;
15741576
}
15751577

15761578
/// Adjusts the channel liquidity balance bounds when successfully routing `amount_msat`.
@@ -1580,6 +1582,7 @@ DirectedChannelLiquidity<L, HT, T> {
15801582
let max_liquidity_msat = self.max_liquidity_msat().checked_sub(amount_msat).unwrap_or(0);
15811583
log_debug!(logger, "Subtracting {} from max liquidity of {} (setting it to {})", amount_msat, chan_descr, max_liquidity_msat);
15821584
self.set_max_liquidity_msat(max_liquidity_msat, duration_since_epoch);
1585+
*self.last_datapoint_time = duration_since_epoch;
15831586
self.update_history_buckets(amount_msat, duration_since_epoch);
15841587
}
15851588

@@ -1603,7 +1606,6 @@ DirectedChannelLiquidity<L, HT, T> {
16031606
*self.max_liquidity_offset_msat = 0;
16041607
}
16051608
*self.last_updated = duration_since_epoch;
1606-
*self.last_datapoint_time = duration_since_epoch;
16071609
}
16081610

16091611
/// Adjusts the upper bound of the channel liquidity balance in this direction.
@@ -1613,7 +1615,6 @@ DirectedChannelLiquidity<L, HT, T> {
16131615
*self.min_liquidity_offset_msat = 0;
16141616
}
16151617
*self.last_updated = duration_since_epoch;
1616-
*self.last_datapoint_time = duration_since_epoch;
16171618
}
16181619
}
16191620

@@ -4143,7 +4144,7 @@ mod tests {
41434144
scorer.payment_path_failed(&payment_path_for_amount(500), 42, Duration::ZERO);
41444145

41454146
// Apply an update to set the last-update time to 1 second
4146-
scorer.payment_path_failed(&payment_path_for_amount(490), 42, Duration::from_secs(1));
4147+
scorer.payment_path_failed(&payment_path_for_amount(500), 42, Duration::from_secs(1));
41474148

41484149
// If no time has passed, we get the full probing_diversity_penalty_msat
41494150
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 1_000_000);

0 commit comments

Comments
 (0)