[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / ScoringParameters.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 [`Scorer`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ScoringParameters extends CommonBase {
16         ScoringParameters(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ScoringParameters_free(ptr); }
21         }
22
23         /**
24          * A fixed penalty in msats to apply to each channel.
25          * 
26          * Default value: 500 msat
27          */
28         public long get_base_penalty_msat() {
29                 long ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * A fixed penalty in msats to apply to each channel.
36          * 
37          * Default value: 500 msat
38          */
39         public void set_base_penalty_msat(long val) {
40                 bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * A penalty in msats to apply to a channel upon failing to relay a payment.
47          * 
48          * This accumulates for each failure but may be reduced over time based on
49          * [`failure_penalty_half_life`] or when successfully routing through a channel.
50          * 
51          * Default value: 1,024,000 msat
52          * 
53          * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
54          */
55         public long get_failure_penalty_msat() {
56                 long ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr);
57                 Reference.reachabilityFence(this);
58                 return ret;
59         }
60
61         /**
62          * A penalty in msats to apply to a channel upon failing to relay a payment.
63          * 
64          * This accumulates for each failure but may be reduced over time based on
65          * [`failure_penalty_half_life`] or when successfully routing through a channel.
66          * 
67          * Default value: 1,024,000 msat
68          * 
69          * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
70          */
71         public void set_failure_penalty_msat(long val) {
72                 bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val);
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(val);
75         }
76
77         /**
78          * When the amount being sent over a channel is this many 1024ths of the total channel
79          * capacity, we begin applying [`overuse_penalty_msat_per_1024th`].
80          * 
81          * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel)
82          * 
83          * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th
84          */
85         public short get_overuse_penalty_start_1024th() {
86                 short ret = bindings.ScoringParameters_get_overuse_penalty_start_1024th(this.ptr);
87                 Reference.reachabilityFence(this);
88                 return ret;
89         }
90
91         /**
92          * When the amount being sent over a channel is this many 1024ths of the total channel
93          * capacity, we begin applying [`overuse_penalty_msat_per_1024th`].
94          * 
95          * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel)
96          * 
97          * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th
98          */
99         public void set_overuse_penalty_start_1024th(short val) {
100                 bindings.ScoringParameters_set_overuse_penalty_start_1024th(this.ptr, val);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent
107          * over the channel exceeds [`overuse_penalty_start_1024th`] by.
108          * 
109          * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty
110          * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel)
111          * 
112          * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th
113          */
114         public long get_overuse_penalty_msat_per_1024th() {
115                 long ret = bindings.ScoringParameters_get_overuse_penalty_msat_per_1024th(this.ptr);
116                 Reference.reachabilityFence(this);
117                 return ret;
118         }
119
120         /**
121          * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent
122          * over the channel exceeds [`overuse_penalty_start_1024th`] by.
123          * 
124          * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty
125          * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel)
126          * 
127          * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th
128          */
129         public void set_overuse_penalty_msat_per_1024th(long val) {
130                 bindings.ScoringParameters_set_overuse_penalty_msat_per_1024th(this.ptr, val);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
137          * cut in half.
138          * 
139          * Successfully routing through a channel will immediately cut the penalty in half as well.
140          * 
141          * Default value: 1 hour
142          * 
143          * # Note
144          * 
145          * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will
146          * never decay.
147          * 
148          * [`failure_penalty_msat`]: Self::failure_penalty_msat
149          */
150         public long get_failure_penalty_half_life() {
151                 long ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156         /**
157          * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
158          * cut in half.
159          * 
160          * Successfully routing through a channel will immediately cut the penalty in half as well.
161          * 
162          * Default value: 1 hour
163          * 
164          * # Note
165          * 
166          * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will
167          * never decay.
168          * 
169          * [`failure_penalty_msat`]: Self::failure_penalty_msat
170          */
171         public void set_failure_penalty_half_life(long val) {
172                 bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val);
173                 Reference.reachabilityFence(this);
174                 Reference.reachabilityFence(val);
175         }
176
177         /**
178          * Constructs a new ScoringParameters given each field
179          */
180         public static ScoringParameters of(long base_penalty_msat_arg, long failure_penalty_msat_arg, short overuse_penalty_start_1024th_arg, long overuse_penalty_msat_per_1024th_arg, long failure_penalty_half_life_arg) {
181                 long ret = bindings.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
182                 Reference.reachabilityFence(base_penalty_msat_arg);
183                 Reference.reachabilityFence(failure_penalty_msat_arg);
184                 Reference.reachabilityFence(overuse_penalty_start_1024th_arg);
185                 Reference.reachabilityFence(overuse_penalty_msat_per_1024th_arg);
186                 Reference.reachabilityFence(failure_penalty_half_life_arg);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
189                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
190                 return ret_hu_conv;
191         }
192
193         long clone_ptr() {
194                 long ret = bindings.ScoringParameters_clone_ptr(this.ptr);
195                 Reference.reachabilityFence(this);
196                 return ret;
197         }
198
199         /**
200          * Creates a copy of the ScoringParameters
201          */
202         public ScoringParameters clone() {
203                 long ret = bindings.ScoringParameters_clone(this.ptr);
204                 Reference.reachabilityFence(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
207                 ret_hu_conv.ptrs_to.add(this);
208                 return ret_hu_conv;
209         }
210
211         /**
212          * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
213          */
214         public byte[] write() {
215                 byte[] ret = bindings.ScoringParameters_write(this.ptr);
216                 Reference.reachabilityFence(this);
217                 return ret;
218         }
219
220         /**
221          * Read a ScoringParameters from a byte array, created by ScoringParameters_write
222          */
223         public static Result_ScoringParametersDecodeErrorZ read(byte[] ser) {
224                 long ret = bindings.ScoringParameters_read(ser);
225                 Reference.reachabilityFence(ser);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
228                 return ret_hu_conv;
229         }
230
231         /**
232          * Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used.
233          */
234         public static ScoringParameters with_default() {
235                 long ret = bindings.ScoringParameters_default();
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
238                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
239                 return ret_hu_conv;
240         }
241
242 }