1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Parameters for configuring [`ProbabilisticScorer`].
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ProbabilisticScoringParameters extends CommonBase {
16 ProbabilisticScoringParameters(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ProbabilisticScoringParameters_free(ptr); }
24 * A multiplier used to determine the amount in msats willing to be paid to avoid routing
25 * through a channel, as per multiplying by the negative `log10` of the channel's success
26 * probability for a payment.
28 * The success probability is determined by the effective channel capacity, the payment amount,
29 * and knowledge learned from prior successful and unsuccessful payments. The lower bound of
30 * the success probability is 0.01, effectively limiting the penalty to the range
31 * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
32 * on [`liquidity_offset_half_life`].
34 * Default value: 10,000 msat
36 * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
38 public long get_liquidity_penalty_multiplier_msat() {
39 long ret = bindings.ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this.ptr);
40 Reference.reachabilityFence(this);
45 * A multiplier used to determine the amount in msats willing to be paid to avoid routing
46 * through a channel, as per multiplying by the negative `log10` of the channel's success
47 * probability for a payment.
49 * The success probability is determined by the effective channel capacity, the payment amount,
50 * and knowledge learned from prior successful and unsuccessful payments. The lower bound of
51 * the success probability is 0.01, effectively limiting the penalty to the range
52 * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
53 * on [`liquidity_offset_half_life`].
55 * Default value: 10,000 msat
57 * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
59 public void set_liquidity_penalty_multiplier_msat(long val) {
60 bindings.ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The time required to elapse before any knowledge learned about channel liquidity balances is
69 * The bounds are defined in terms of offsets and are initially zero. Increasing the offsets
70 * gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases
71 * the certainty of the channel liquidity balance.
73 * Default value: 1 hour
77 * When built with the `no-std` feature, time will never elapse. Therefore, the channel
78 * liquidity knowledge will never decay except when the bounds cross.
80 public long get_liquidity_offset_half_life() {
81 long ret = bindings.ProbabilisticScoringParameters_get_liquidity_offset_half_life(this.ptr);
82 Reference.reachabilityFence(this);
87 * The time required to elapse before any knowledge learned about channel liquidity balances is
90 * The bounds are defined in terms of offsets and are initially zero. Increasing the offsets
91 * gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases
92 * the certainty of the channel liquidity balance.
94 * Default value: 1 hour
98 * When built with the `no-std` feature, time will never elapse. Therefore, the channel
99 * liquidity knowledge will never decay except when the bounds cross.
101 public void set_liquidity_offset_half_life(long val) {
102 bindings.ProbabilisticScoringParameters_set_liquidity_offset_half_life(this.ptr, val);
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(val);
108 * Constructs a new ProbabilisticScoringParameters given each field
110 public static ProbabilisticScoringParameters of(long liquidity_penalty_multiplier_msat_arg, long liquidity_offset_half_life_arg) {
111 long ret = bindings.ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
112 Reference.reachabilityFence(liquidity_penalty_multiplier_msat_arg);
113 Reference.reachabilityFence(liquidity_offset_half_life_arg);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 ProbabilisticScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ProbabilisticScoringParameters(null, ret); }
116 ret_hu_conv.ptrs_to.add(ret_hu_conv);
121 long ret = bindings.ProbabilisticScoringParameters_clone_ptr(this.ptr);
122 Reference.reachabilityFence(this);
127 * Creates a copy of the ProbabilisticScoringParameters
129 public ProbabilisticScoringParameters clone() {
130 long ret = bindings.ProbabilisticScoringParameters_clone(this.ptr);
131 Reference.reachabilityFence(this);
132 if (ret >= 0 && ret <= 4096) { return null; }
133 ProbabilisticScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ProbabilisticScoringParameters(null, ret); }
134 ret_hu_conv.ptrs_to.add(this);
139 * Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read
141 public byte[] write() {
142 byte[] ret = bindings.ProbabilisticScoringParameters_write(this.ptr);
143 Reference.reachabilityFence(this);
148 * Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write
150 public static Result_ProbabilisticScoringParametersDecodeErrorZ read(byte[] ser) {
151 long ret = bindings.ProbabilisticScoringParameters_read(ser);
152 Reference.reachabilityFence(ser);
153 if (ret >= 0 && ret <= 4096) { return null; }
154 Result_ProbabilisticScoringParametersDecodeErrorZ ret_hu_conv = Result_ProbabilisticScoringParametersDecodeErrorZ.constr_from_ptr(ret);
159 * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used.
161 public static ProbabilisticScoringParameters with_default() {
162 long ret = bindings.ProbabilisticScoringParameters_default();
163 if (ret >= 0 && ret <= 4096) { return null; }
164 ProbabilisticScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ProbabilisticScoringParameters(null, ret); }
165 ret_hu_conv.ptrs_to.add(ret_hu_conv);