Skip to content

Commit bf19429

Browse files
authored
Merge pull request #1342 from TheBlueMatt/2022-03-fix-bindings-docs
Fix feature-specific documentation
2 parents 5009528 + 1c5572b commit bf19429

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
@@ -215,6 +215,7 @@ impl Score for FixedPenaltyScorer {
215215
fn payment_path_successful(&mut self, _path: &[&RouteHop]) {}
216216
}
217217

218+
#[cfg(not(feature = "no-std"))]
218219
/// [`Score`] implementation that provides reasonable default behavior.
219220
///
220221
/// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
@@ -232,9 +233,21 @@ impl Score for FixedPenaltyScorer {
232233
since = "0.0.105",
233234
note = "ProbabilisticScorer should be used instead of Scorer.",
234235
)]
235-
#[cfg(not(feature = "no-std"))]
236236
pub type Scorer = ScorerUsingTime::<std::time::Instant>;
237237
#[cfg(feature = "no-std")]
238+
/// [`Score`] implementation that provides reasonable default behavior.
239+
///
240+
/// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
241+
/// slightly higher fees are available. Will further penalize channels that fail to relay payments.
242+
///
243+
/// See [module-level documentation] for usage and [`ScoringParameters`] for customization.
244+
///
245+
/// # Note
246+
///
247+
/// Mixing the `no-std` feature between serialization and deserialization results in undefined
248+
/// behavior.
249+
///
250+
/// [module-level documentation]: crate::routing::scoring
238251
pub type Scorer = ScorerUsingTime::<time::Eternity>;
239252

240253
// Note that ideally we'd hide ScorerUsingTime from public view by sealing it as well, but rustdoc
@@ -463,6 +476,7 @@ impl<T: Time> Readable for ChannelFailure<T> {
463476
}
464477
}
465478

479+
#[cfg(not(feature = "no-std"))]
466480
/// [`Score`] implementation using channel success probability distributions.
467481
///
468482
/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
@@ -485,9 +499,30 @@ impl<T: Time> Readable for ChannelFailure<T> {
485499
/// behavior.
486500
///
487501
/// [1]: https://arxiv.org/abs/2107.05322
488-
#[cfg(not(feature = "no-std"))]
489502
pub type ProbabilisticScorer<G> = ProbabilisticScorerUsingTime::<G, std::time::Instant>;
490503
#[cfg(feature = "no-std")]
504+
/// [`Score`] implementation using channel success probability distributions.
505+
///
506+
/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
507+
/// and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability
508+
/// distributions are defined based on knowledge learned from successful and unsuccessful attempts.
509+
/// Then the negative `log10` of the success probability is used to determine the cost of routing a
510+
/// specific HTLC amount through a channel.
511+
///
512+
/// Knowledge about channel liquidity balances takes the form of upper and lower bounds on the
513+
/// possible liquidity. Certainty of the bounds is decreased over time using a decay function. See
514+
/// [`ProbabilisticScoringParameters`] for details.
515+
///
516+
/// Since the scorer aims to learn the current channel liquidity balances, it works best for nodes
517+
/// with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment
518+
/// volume are more likely to experience failed payment paths, which would need to be retried.
519+
///
520+
/// # Note
521+
///
522+
/// Mixing the `no-std` feature between serialization and deserialization results in undefined
523+
/// behavior.
524+
///
525+
/// [1]: https://arxiv.org/abs/2107.05322
491526
pub type ProbabilisticScorer<G> = ProbabilisticScorerUsingTime::<G, time::Eternity>;
492527

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

0 commit comments

Comments
 (0)