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 * Used to configure decay parameters that are static throughout the lifetime of the scorer.
15 * these decay parameters affect the score of the channel penalty and are not changed on a
16 * per-route penalty cost call.
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class ProbabilisticScoringDecayParameters extends CommonBase {
20 ProbabilisticScoringDecayParameters(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.ProbabilisticScoringDecayParameters_free(ptr); }
28 * If we aren't learning any new datapoints for a channel, the historical liquidity bounds
29 * tracking can simply live on with increasingly stale data. Instead, when a channel has not
30 * seen a liquidity estimate update for this amount of time, the historical datapoints are
32 * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`]
34 * Note that after 16 or more half lives all historical data will be completely gone.
36 * Default value: 14 days
38 * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities
40 public long get_historical_no_updates_half_life() {
41 long ret = bindings.ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(this.ptr);
42 Reference.reachabilityFence(this);
47 * If we aren't learning any new datapoints for a channel, the historical liquidity bounds
48 * tracking can simply live on with increasingly stale data. Instead, when a channel has not
49 * seen a liquidity estimate update for this amount of time, the historical datapoints are
51 * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`]
53 * Note that after 16 or more half lives all historical data will be completely gone.
55 * Default value: 14 days
57 * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities
59 public void set_historical_no_updates_half_life(long val) {
60 bindings.ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Whenever this amount of time elapses since the last update to a channel's liquidity bounds,
67 * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on
68 * the available liquidity is halved and the upper-bound moves half-way to the channel's total
71 * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity,
72 * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`]
73 * struct documentation for more info on the way the liquidity bounds are used.
75 * For example, if the channel's capacity is 1 million sats, and the current upper and lower
76 * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper
77 * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats.
79 * Default value: 6 hours
83 * When built with the `no-std` feature, time will never elapse. Therefore, the channel
84 * liquidity knowledge will never decay except when the bounds cross.
86 public long get_liquidity_offset_half_life() {
87 long ret = bindings.ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(this.ptr);
88 Reference.reachabilityFence(this);
93 * Whenever this amount of time elapses since the last update to a channel's liquidity bounds,
94 * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on
95 * the available liquidity is halved and the upper-bound moves half-way to the channel's total
98 * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity,
99 * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`]
100 * struct documentation for more info on the way the liquidity bounds are used.
102 * For example, if the channel's capacity is 1 million sats, and the current upper and lower
103 * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper
104 * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats.
106 * Default value: 6 hours
110 * When built with the `no-std` feature, time will never elapse. Therefore, the channel
111 * liquidity knowledge will never decay except when the bounds cross.
113 public void set_liquidity_offset_half_life(long val) {
114 bindings.ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(this.ptr, val);
115 Reference.reachabilityFence(this);
116 Reference.reachabilityFence(val);
120 * Constructs a new ProbabilisticScoringDecayParameters given each field
122 public static ProbabilisticScoringDecayParameters of(long historical_no_updates_half_life_arg, long liquidity_offset_half_life_arg) {
123 long ret = bindings.ProbabilisticScoringDecayParameters_new(historical_no_updates_half_life_arg, liquidity_offset_half_life_arg);
124 Reference.reachabilityFence(historical_no_updates_half_life_arg);
125 Reference.reachabilityFence(liquidity_offset_half_life_arg);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.ProbabilisticScoringDecayParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ProbabilisticScoringDecayParameters(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
133 long ret = bindings.ProbabilisticScoringDecayParameters_clone_ptr(this.ptr);
134 Reference.reachabilityFence(this);
139 * Creates a copy of the ProbabilisticScoringDecayParameters
141 public ProbabilisticScoringDecayParameters clone() {
142 long ret = bindings.ProbabilisticScoringDecayParameters_clone(this.ptr);
143 Reference.reachabilityFence(this);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.ProbabilisticScoringDecayParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ProbabilisticScoringDecayParameters(null, ret); }
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
151 * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used.
153 public static ProbabilisticScoringDecayParameters with_default() {
154 long ret = bindings.ProbabilisticScoringDecayParameters_default();
155 if (ret >= 0 && ret <= 4096) { return null; }
156 org.ldk.structs.ProbabilisticScoringDecayParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ProbabilisticScoringDecayParameters(null, ret); }
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };