Skip to content

Commit 877d9cf

Browse files
committed
f address docs feedback
1 parent ecdcffa commit 877d9cf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lightning/src/routing/scoring.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,23 @@ type ConfiguredTime = Eternity;
314314

315315
/// [`Score`] implementation using channel success probability distributions.
316316
///
317-
/// Channels are tracked with upper- and lower- liquidity bounds - when an HTLC fails at a channel,
317+
/// Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel,
318318
/// we learn that the upper-bound on the available liquidity is lower than the amount of the HTLC.
319319
/// When a payment is forwarded through a channel (but fails later in the route), we learn the
320320
/// lower-bound on the channel's available liquidity must be at least the value of the HTLC.
321321
///
322322
/// These bounds are then used to determine a success probability using the formula from
323323
/// *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
324-
/// and Stefan Richter [[1]] (i.e. `(payment amount + lower-bound) / (upper-bound - lower-bound)`).
324+
/// and Stefan Richter [[1]] (i.e. `(upper_bound - payment_amount) / (upper_bound - lower_bound)`).
325325
///
326-
/// This probability is converted into a linear score and multiplying it with the
326+
/// This probability is converted into a linear score and multiplied with the
327327
/// [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]
328-
/// parameters to get a concrete msat value. See the documentation for those parameters for the
328+
/// parameters to get a concrete msat penalty. See the documentation for those parameters for the
329329
/// exact formulas.
330330
///
331331
/// The liquidity bounds are then decayed by halving them every [`liquidity_offset_half_life`].
332332
///
333-
/// Further, we track the history of our upper- and lower- liquidity bounds for each channel,
333+
/// Further, we track the history of our upper and lower liquidity bounds for each channel,
334334
/// allowing us to assign a second penalty (using [`historical_liquidity_penalty_multiplier_msat`]
335335
/// and [`historical_liquidity_penalty_amount_multiplier_msat`]) based on the same probability
336336
/// formula, but using the history of a channel rather than our latest estimates for the liquidity
@@ -406,15 +406,16 @@ pub struct ProbabilisticScoringParameters {
406406
/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
407407
pub liquidity_penalty_multiplier_msat: u64,
408408

409-
/// We track upper and lower bounds on the available liquidity in a channel in order to
410-
/// calculate success probability given recent successes and failures. In order to ensure we do
411-
/// not get stuck avoiding channels which only failed once, we decay these bounds over time.
412-
///
413409
/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds,
414410
/// the distance from the bounds to "zero" is cut in half. In other words, the lower-bound on
415411
/// the available liquidity is halved and the upper-bound moves half-way to the channel's total
416412
/// capacity.
417413
///
414+
/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity,
415+
/// penalties for payments that are within the liquidity bounds will be decreased. See the
416+
/// [`ProbabilisticScorer`] struct documentation for more info on the way the liquidity bounds
417+
/// are used.
418+
///
418419
/// For example, if the channel's capacity is 1 million sats, and the current upper- and lower-
419420
/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper-
420421
/// and lower- liquidity bounds will be decayed to 100,000 and 800,000 sats.

0 commit comments

Comments
 (0)