1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Parameters for configuring [`Scorer`].
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 {
19 if (ptr != 0) { bindings.ScoringParameters_free(ptr); }
23 * A fixed penalty in msats to apply to each channel.
25 public long get_base_penalty_msat() {
26 long ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr);
31 * A fixed penalty in msats to apply to each channel.
33 public void set_base_penalty_msat(long val) {
34 bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val);
38 * A penalty in msats to apply to a channel upon failing to relay a payment.
40 * This accumulates for each failure but may be reduced over time based on
41 * [`failure_penalty_half_life`].
43 * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
45 public long get_failure_penalty_msat() {
46 long ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr);
51 * A penalty in msats to apply to a channel upon failing to relay a payment.
53 * This accumulates for each failure but may be reduced over time based on
54 * [`failure_penalty_half_life`].
56 * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
58 public void set_failure_penalty_msat(long val) {
59 bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val);
63 * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
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.
71 * [`failure_penalty_msat`]: Self::failure_penalty_msat
73 public long get_failure_penalty_half_life() {
74 long ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr);
79 * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
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.
87 * [`failure_penalty_msat`]: Self::failure_penalty_msat
89 public void set_failure_penalty_half_life(long val) {
90 bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val);
94 * Constructs a new ScoringParameters given each field
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);
105 * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
107 public byte[] write() {
108 byte[] ret = bindings.ScoringParameters_write(this.ptr);
113 * Read a ScoringParameters from a byte array, created by ScoringParameters_write
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);
123 * Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used.
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);