Update auto-generated bindings to 0.0.103
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Parameters for configuring [`Scorer`].
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ScoringParameters extends CommonBase {
15         ScoringParameters(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ScoringParameters_free(ptr); }
20         }
21
22         /**
23          * A fixed penalty in msats to apply to each channel.
24          */
25         public long get_base_penalty_msat() {
26                 long ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * A fixed penalty in msats to apply to each channel.
32          */
33         public void set_base_penalty_msat(long val) {
34                 bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val);
35         }
36
37         /**
38          * A penalty in msats to apply to a channel upon failing to relay a payment.
39          * 
40          * This accumulates for each failure but may be reduced over time based on
41          * [`failure_penalty_half_life`].
42          * 
43          * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
44          */
45         public long get_failure_penalty_msat() {
46                 long ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr);
47                 return ret;
48         }
49
50         /**
51          * A penalty in msats to apply to a channel upon failing to relay a payment.
52          * 
53          * This accumulates for each failure but may be reduced over time based on
54          * [`failure_penalty_half_life`].
55          * 
56          * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
57          */
58         public void set_failure_penalty_msat(long val) {
59                 bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val);
60         }
61
62         /**
63          * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
64          * cut in half.
65          * 
66          * # Note
67          * 
68          * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
69          * elapse. Therefore, this penalty will never decay.
70          * 
71          * [`failure_penalty_msat`]: Self::failure_penalty_msat
72          */
73         public long get_failure_penalty_half_life() {
74                 long ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr);
75                 return ret;
76         }
77
78         /**
79          * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
80          * cut in half.
81          * 
82          * # Note
83          * 
84          * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
85          * elapse. Therefore, this penalty will never decay.
86          * 
87          * [`failure_penalty_msat`]: Self::failure_penalty_msat
88          */
89         public void set_failure_penalty_half_life(long val) {
90                 bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val);
91         }
92
93         /**
94          * Constructs a new ScoringParameters given each field
95          */
96         public static ScoringParameters of(long base_penalty_msat_arg, long failure_penalty_msat_arg, long failure_penalty_half_life_arg) {
97                 long ret = bindings.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
100                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
106          */
107         public byte[] write() {
108                 byte[] ret = bindings.ScoringParameters_write(this.ptr);
109                 return ret;
110         }
111
112         /**
113          * Read a ScoringParameters from a byte array, created by ScoringParameters_write
114          */
115         public static Result_ScoringParametersDecodeErrorZ read(byte[] ser) {
116                 long ret = bindings.ScoringParameters_read(ser);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used.
124          */
125         public static ScoringParameters with_default() {
126                 long ret = bindings.ScoringParameters_default();
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
129                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
130                 return ret_hu_conv;
131         }
132
133 }