X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FScoringParameters.java;h=d0360a5b981b0f49bf22142dabbdf6fd4df1bf91;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=eccd438aefe01250fdbeccc40ad8fc7e7178125d;hpb=5fd405f7a48aaeca779c45c88ec6b3d3d3dbf0e4;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ScoringParameters.java b/src/main/java/org/ldk/structs/ScoringParameters.java index eccd438a..d0360a5b 100644 --- a/src/main/java/org/ldk/structs/ScoringParameters.java +++ b/src/main/java/org/ldk/structs/ScoringParameters.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; import javax.annotation.Nullable; @@ -21,29 +22,39 @@ public class ScoringParameters extends CommonBase { /** * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ public long get_base_penalty_msat() { long ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr); + Reference.reachabilityFence(this); return ret; } /** * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ public void set_base_penalty_msat(long val) { bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** * A penalty in msats to apply to a channel upon failing to relay a payment. * * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`]. + * [`failure_penalty_half_life`] or when successfully routing through a channel. + * + * Default value: 1,024,000 msat * * [`failure_penalty_half_life`]: Self::failure_penalty_half_life */ public long get_failure_penalty_msat() { long ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -51,27 +62,92 @@ public class ScoringParameters extends CommonBase { * A penalty in msats to apply to a channel upon failing to relay a payment. * * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`]. + * [`failure_penalty_half_life`] or when successfully routing through a channel. + * + * Default value: 1,024,000 msat * * [`failure_penalty_half_life`]: Self::failure_penalty_half_life */ public void set_failure_penalty_msat(long val) { bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * When the amount being sent over a channel is this many 1024ths of the total channel + * capacity, we begin applying [`overuse_penalty_msat_per_1024th`]. + * + * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * + * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + */ + public short get_overuse_penalty_start_1024th() { + short ret = bindings.ScoringParameters_get_overuse_penalty_start_1024th(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * When the amount being sent over a channel is this many 1024ths of the total channel + * capacity, we begin applying [`overuse_penalty_msat_per_1024th`]. + * + * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * + * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + */ + public void set_overuse_penalty_start_1024th(short val) { + bindings.ScoringParameters_set_overuse_penalty_start_1024th(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent + * over the channel exceeds [`overuse_penalty_start_1024th`] by. + * + * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty + * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel) + * + * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + */ + public long get_overuse_penalty_msat_per_1024th() { + long ret = bindings.ScoringParameters_get_overuse_penalty_msat_per_1024th(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent + * over the channel exceeds [`overuse_penalty_start_1024th`] by. + * + * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty + * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel) + * + * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + */ + public void set_overuse_penalty_msat_per_1024th(long val) { + bindings.ScoringParameters_set_overuse_penalty_msat_per_1024th(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are * cut in half. * + * Successfully routing through a channel will immediately cut the penalty in half as well. + * * # Note * - * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never - * elapse. Therefore, this penalty will never decay. + * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will + * never decay. * * [`failure_penalty_msat`]: Self::failure_penalty_msat */ public long get_failure_penalty_half_life() { long ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -79,22 +155,31 @@ public class ScoringParameters extends CommonBase { * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are * cut in half. * + * Successfully routing through a channel will immediately cut the penalty in half as well. + * * # Note * - * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never - * elapse. Therefore, this penalty will never decay. + * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will + * never decay. * * [`failure_penalty_msat`]: Self::failure_penalty_msat */ public void set_failure_penalty_half_life(long val) { bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** * Constructs a new ScoringParameters given each field */ - public static ScoringParameters of(long base_penalty_msat_arg, long failure_penalty_msat_arg, long failure_penalty_half_life_arg) { - long ret = bindings.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg); + 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) { + 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); + Reference.reachabilityFence(base_penalty_msat_arg); + Reference.reachabilityFence(failure_penalty_msat_arg); + Reference.reachabilityFence(overuse_penalty_start_1024th_arg); + Reference.reachabilityFence(overuse_penalty_msat_per_1024th_arg); + Reference.reachabilityFence(failure_penalty_half_life_arg); if (ret >= 0 && ret <= 4096) { return null; } ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); @@ -106,6 +191,7 @@ public class ScoringParameters extends CommonBase { */ public byte[] write() { byte[] ret = bindings.ScoringParameters_write(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -114,6 +200,7 @@ public class ScoringParameters extends CommonBase { */ public static Result_ScoringParametersDecodeErrorZ read(byte[] ser) { long ret = bindings.ScoringParameters_read(ser); + Reference.reachabilityFence(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv;