X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Fscoring.rs;h=335a6f1a23411a6ab5c4ccad2fd2a478857bc38b;hb=0357f6a8c9ce3192fb457f4082b2becde7bc58c5;hp=b7aa996ce2efae9622208e1293dcebf8b1b3d8b9;hpb=af318312c5a12f3cb3b6e1af788b3bd620d4dbe5;p=rust-lightning diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index b7aa996c..335a6f1a 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -230,6 +230,7 @@ impl ReadableArgs for FixedPenaltyScorer { } } +#[cfg(not(feature = "no-std"))] /// [`Score`] implementation that provides reasonable default behavior. /// /// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with @@ -247,12 +248,22 @@ impl ReadableArgs for FixedPenaltyScorer { since = "0.0.105", note = "ProbabilisticScorer should be used instead of Scorer.", )] -pub type Scorer = ScorerUsingTime::; - -#[cfg(not(feature = "no-std"))] -type ConfiguredTime = std::time::Instant; +pub type Scorer = ScorerUsingTime::; #[cfg(feature = "no-std")] -type ConfiguredTime = time::Eternity; +/// [`Score`] implementation that provides reasonable default behavior. +/// +/// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with +/// slightly higher fees are available. Will further penalize channels that fail to relay payments. +/// +/// See [module-level documentation] for usage and [`ScoringParameters`] for customization. +/// +/// # Note +/// +/// Mixing the `no-std` feature between serialization and deserialization results in undefined +/// behavior. +/// +/// [module-level documentation]: crate::routing::scoring +pub type Scorer = ScorerUsingTime::; // Note that ideally we'd hide ScorerUsingTime from public view by sealing it as well, but rustdoc // doesn't handle this well - instead exposing a `Scorer` which has no trait implementation(s) or @@ -481,6 +492,31 @@ impl Readable for ChannelFailure { } } +#[cfg(not(feature = "no-std"))] +/// [`Score`] implementation using channel success probability distributions. +/// +/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt +/// and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability +/// distributions are defined based on knowledge learned from successful and unsuccessful attempts. +/// Then the negative `log10` of the success probability is used to determine the cost of routing a +/// specific HTLC amount through a channel. +/// +/// Knowledge about channel liquidity balances takes the form of upper and lower bounds on the +/// possible liquidity. Certainty of the bounds is decreased over time using a decay function. See +/// [`ProbabilisticScoringParameters`] for details. +/// +/// Since the scorer aims to learn the current channel liquidity balances, it works best for nodes +/// with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment +/// volume are more likely to experience failed payment paths, which would need to be retried. +/// +/// # Note +/// +/// Mixing the `no-std` feature between serialization and deserialization results in undefined +/// behavior. +/// +/// [1]: https://arxiv.org/abs/2107.05322 +pub type ProbabilisticScorer = ProbabilisticScorerUsingTime::; +#[cfg(feature = "no-std")] /// [`Score`] implementation using channel success probability distributions. /// /// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt @@ -503,7 +539,7 @@ impl Readable for ChannelFailure { /// behavior. /// /// [1]: https://arxiv.org/abs/2107.05322 -pub type ProbabilisticScorer = ProbabilisticScorerUsingTime::; +pub type ProbabilisticScorer = ProbabilisticScorerUsingTime::; /// Probabilistic [`Score`] implementation. ///