b4edd287173c41e6cb6d4ff3a8d64495c85fbe41
[ldk-java] / src / main / java / org / ldk / structs / ProbabilisticScoringDecayParameters.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Parameters for configuring [`ProbabilisticScorer`].
13  * 
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.
17  */
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 {
23                 super.finalize();
24                 if (ptr != 0) { bindings.ProbabilisticScoringDecayParameters_free(ptr); }
25         }
26
27         /**
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
31          * decayed by half.
32          * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`]
33          * 
34          * Note that after 16 or more half lives all historical data will be completely gone.
35          * 
36          * Default value: 14 days
37          * 
38          * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities
39          */
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);
43                 return ret;
44         }
45
46         /**
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
50          * decayed by half.
51          * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`]
52          * 
53          * Note that after 16 or more half lives all historical data will be completely gone.
54          * 
55          * Default value: 14 days
56          * 
57          * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities
58          */
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);
63         }
64
65         /**
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
69          * capacity.
70          * 
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.
74          * 
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.
78          * 
79          * Default value: 6 hours
80          * 
81          * # Note
82          * 
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.
85          */
86         public long get_liquidity_offset_half_life() {
87                 long ret = bindings.ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         /**
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
96          * capacity.
97          * 
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.
101          * 
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.
105          * 
106          * Default value: 6 hours
107          * 
108          * # Note
109          * 
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.
112          */
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);
117         }
118
119         /**
120          * Constructs a new ProbabilisticScoringDecayParameters given each field
121          */
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); };
129                 return ret_hu_conv;
130         }
131
132         long clone_ptr() {
133                 long ret = bindings.ProbabilisticScoringDecayParameters_clone_ptr(this.ptr);
134                 Reference.reachabilityFence(this);
135                 return ret;
136         }
137
138         /**
139          * Creates a copy of the ProbabilisticScoringDecayParameters
140          */
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); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used.
152          */
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); };
158                 return ret_hu_conv;
159         }
160
161 }