ebace911f658f74455733e0642444bdcd378e0a0
[ldk-java] / src / main / java / org / ldk / structs / ProbabilisticScoringParameters.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 @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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ProbabilisticScoringParameters_free(ptr); }
21         }
22
23         /**
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.
27          * 
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`].
33          * 
34          * Default value: 10,000 msat
35          * 
36          * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
37          */
38         public long get_liquidity_penalty_multiplier_msat() {
39                 long ret = bindings.ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this.ptr);
40                 Reference.reachabilityFence(this);
41                 return ret;
42         }
43
44         /**
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.
48          * 
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`].
54          * 
55          * Default value: 10,000 msat
56          * 
57          * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
58          */
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);
63         }
64
65         /**
66          * The time required to elapse before any knowledge learned about channel liquidity balances is
67          * cut in half.
68          * 
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.
72          * 
73          * Default value: 1 hour
74          * 
75          * # Note
76          * 
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.
79          */
80         public long get_liquidity_offset_half_life() {
81                 long ret = bindings.ProbabilisticScoringParameters_get_liquidity_offset_half_life(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * The time required to elapse before any knowledge learned about channel liquidity balances is
88          * cut in half.
89          * 
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.
93          * 
94          * Default value: 1 hour
95          * 
96          * # Note
97          * 
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.
100          */
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);
105         }
106
107         /**
108          * Constructs a new ProbabilisticScoringParameters given each field
109          */
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);
117                 return ret_hu_conv;
118         }
119
120         long clone_ptr() {
121                 long ret = bindings.ProbabilisticScoringParameters_clone_ptr(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * Creates a copy of the ProbabilisticScoringParameters
128          */
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);
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read
140          */
141         public byte[] write() {
142                 byte[] ret = bindings.ProbabilisticScoringParameters_write(this.ptr);
143                 Reference.reachabilityFence(this);
144                 return ret;
145         }
146
147         /**
148          * Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write
149          */
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);
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used.
160          */
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);
166                 return ret_hu_conv;
167         }
168
169 }