Package org.ldk.structs
Class ProbabilisticScorer
- java.lang.Object
-
- org.ldk.structs.ProbabilisticScorer
-
public class ProbabilisticScorer extends Object
[`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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd_banned(NodeId node_id)Marks the node with the given `node_id` as banned, i.e., it will be avoided during path finding.Scoreas_Score()Constructs a new Score which calls the relevant methods on this_arg.voidclear_manual_penalties()Clears the list of manual penalties that are applied during path finding.voiddebug_log_liquidity_stats()Dump the contents of this scorer into the configured logger.Option_C2Tuple_u64u64ZZestimated_channel_liquidity_range(long scid, NodeId target)Query the estimated minimum and maximum liquidity available for sending a payment over the channel with `scid` towards the given `target` node.protected voidfinalize()static ProbabilisticScorerof(ProbabilisticScoringParameters params, NetworkGraph network_graph, Logger logger)Creates a new scorer using the given scoring parameters for sending payments from a node through a network graph.static Result_ProbabilisticScorerDecodeErrorZread(byte[] ser, ProbabilisticScoringParameters arg_a, NetworkGraph arg_b, Logger arg_c)Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_writevoidremove_banned(NodeId node_id)Removes the node with the given `node_id` from the list of nodes to avoid.voidremove_manual_penalty(NodeId node_id)Removes the node with the given `node_id` from the list of manual penalties.voidset_manual_penalty(NodeId node_id, long penalty)Sets a manual penalty for the given node.byte[]write()Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
of
public static ProbabilisticScorer of(ProbabilisticScoringParameters params, NetworkGraph network_graph, Logger logger)
Creates a new scorer using the given scoring parameters for sending payments from a node through a network graph.
-
debug_log_liquidity_stats
public void debug_log_liquidity_stats()
Dump the contents of this scorer into the configured logger. Note that this writes roughly one line per channel for which we have a liquidity estimate, which may be a substantial amount of log output.
-
estimated_channel_liquidity_range
public Option_C2Tuple_u64u64ZZ estimated_channel_liquidity_range(long scid, NodeId target)
Query the estimated minimum and maximum liquidity available for sending a payment over the channel with `scid` towards the given `target` node.
-
add_banned
public void add_banned(NodeId node_id)
Marks the node with the given `node_id` as banned, i.e., it will be avoided during path finding.
-
remove_banned
public void remove_banned(NodeId node_id)
Removes the node with the given `node_id` from the list of nodes to avoid.
-
set_manual_penalty
public void set_manual_penalty(NodeId node_id, long penalty)
Sets a manual penalty for the given node.
-
remove_manual_penalty
public void remove_manual_penalty(NodeId node_id)
Removes the node with the given `node_id` from the list of manual penalties.
-
clear_manual_penalties
public void clear_manual_penalties()
Clears the list of manual penalties that are applied during path finding.
-
as_Score
public Score as_Score()
Constructs a new Score which calls the relevant methods on this_arg. This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
-
write
public byte[] write()
Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read
-
read
public static Result_ProbabilisticScorerDecodeErrorZ read(byte[] ser, ProbabilisticScoringParameters arg_a, NetworkGraph arg_b, Logger arg_c)
Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write
-
-