Skip to content

Commit ee8defb

Browse files
TheBlueMattjkczyz
authored andcommitted
Fix feature-specific documentation
Apparently documentation only applies to the first feature-specific definition, not both.
1 parent 186df43 commit ee8defb

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

lightning/src/routing/scoring.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
230230
}
231231
}
232232

233+
#[cfg(not(feature = "no-std"))]
233234
/// [`Score`] implementation that provides reasonable default behavior.
234235
///
235236
/// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
@@ -247,9 +248,21 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
247248
since = "0.0.105",
248249
note = "ProbabilisticScorer should be used instead of Scorer.",
249250
)]
250-
#[cfg(not(feature = "no-std"))]
251251
pub type Scorer = ScorerUsingTime::<std::time::Instant>;
252252
#[cfg(feature = "no-std")]
253+
/// [`Score`] implementation that provides reasonable default behavior.
254+
///
255+
/// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
256+
/// slightly higher fees are available. Will further penalize channels that fail to relay payments.
257+
///
258+
/// See [module-level documentation] for usage and [`ScoringParameters`] for customization.
259+
///
260+
/// # Note
261+
///
262+
/// Mixing the `no-std` feature between serialization and deserialization results in undefined
263+
/// behavior.
264+
///
265+
/// [module-level documentation]: crate::routing::scoring
253266
pub type Scorer = ScorerUsingTime::<time::Eternity>;
254267

255268
// Note that ideally we'd hide ScorerUsingTime from public view by sealing it as well, but rustdoc
@@ -479,6 +492,7 @@ impl<T: Time> Readable for ChannelFailure<T> {
479492
}
480493
}
481494

495+
#[cfg(not(feature = "no-std"))]
482496
/// [`Score`] implementation using channel success probability distributions.
483497
///
484498
/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
@@ -501,9 +515,30 @@ impl<T: Time> Readable for ChannelFailure<T> {
501515
/// behavior.
502516
///
503517
/// [1]: https://arxiv.org/abs/2107.05322
504-
#[cfg(not(feature = "no-std"))]
505518
pub type ProbabilisticScorer<G> = ProbabilisticScorerUsingTime::<G, std::time::Instant>;
506519
#[cfg(feature = "no-std")]
520+
/// [`Score`] implementation using channel success probability distributions.
521+
///
522+
/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
523+
/// and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability
524+
/// distributions are defined based on knowledge learned from successful and unsuccessful attempts.
525+
/// Then the negative `log10` of the success probability is used to determine the cost of routing a
526+
/// specific HTLC amount through a channel.
527+
///
528+
/// Knowledge about channel liquidity balances takes the form of upper and lower bounds on the
529+
/// possible liquidity. Certainty of the bounds is decreased over time using a decay function. See
530+
/// [`ProbabilisticScoringParameters`] for details.
531+
///
532+
/// Since the scorer aims to learn the current channel liquidity balances, it works best for nodes
533+
/// with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment
534+
/// volume are more likely to experience failed payment paths, which would need to be retried.
535+
///
536+
/// # Note
537+
///
538+
/// Mixing the `no-std` feature between serialization and deserialization results in undefined
539+
/// behavior.
540+
///
541+
/// [1]: https://arxiv.org/abs/2107.05322
507542
pub type ProbabilisticScorer<G> = ProbabilisticScorerUsingTime::<G, time::Eternity>;
508543

509544
/// Probabilistic [`Score`] implementation.

0 commit comments

Comments
 (0)