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 * [`routing::Score`] implementation that provides reasonable default behavior.
13 * Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
14 * slightly higher fees are available.
16 * See [module-level documentation] for usage.
18 * [module-level documentation]: crate::routing::scorer
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class Scorer extends CommonBase {
22 Scorer(Object _dummy, long ptr) { super(ptr); }
23 @Override @SuppressWarnings("deprecation")
24 protected void finalize() throws Throwable {
26 if (ptr != 0) { bindings.Scorer_free(ptr); }
30 * Creates a new scorer using `base_penalty_msat` as the channel penalty.
32 public static Scorer of(long base_penalty_msat) {
33 long ret = bindings.Scorer_new(base_penalty_msat);
34 if (ret >= 0 && ret < 1024) { return null; }
35 Scorer ret_hu_conv = new Scorer(null, ret);
36 ret_hu_conv.ptrs_to.add(ret_hu_conv);
41 * Creates a "default" Scorer. See struct and individual field documentaiton for details on which values are used.
43 public static Scorer with_default() {
44 long ret = bindings.Scorer_default();
45 if (ret >= 0 && ret < 1024) { return null; }
46 Scorer ret_hu_conv = new Scorer(null, ret);
47 ret_hu_conv.ptrs_to.add(ret_hu_conv);
52 * Constructs a new Score which calls the relevant methods on this_arg.
53 * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
55 public Score as_Score() {
56 long ret = bindings.Scorer_as_Score(this.ptr);
57 if (ret >= 0 && ret < 1024) { return null; }
58 Score ret_hu_conv = new Score(null, ret);
59 ret_hu_conv.ptrs_to.add(this);