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;
10 * An interface used to score payment channels for path finding.
12 * \tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Score extends CommonBase {
16 final bindings.LDKScore bindings_instance;
17 Score(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
18 private Score(bindings.LDKScore arg) {
19 super(bindings.LDKScore_new(arg));
20 this.ptrs_to.add(arg);
21 this.bindings_instance = arg;
23 @Override @SuppressWarnings("deprecation")
24 protected void finalize() throws Throwable {
25 if (ptr != 0) { bindings.Score_free(ptr); } super.finalize();
28 public static interface ScoreInterface {
30 * Returns the fee in msats willing to be paid to avoid routing through the given channel.
32 long channel_penalty_msat(long short_channel_id);
34 private static class LDKScoreHolder { Score held; }
35 public static Score new_impl(ScoreInterface arg) {
36 final LDKScoreHolder impl_holder = new LDKScoreHolder();
37 impl_holder.held = new Score(new bindings.LDKScore() {
38 @Override public long channel_penalty_msat(long short_channel_id) {
39 long ret = arg.channel_penalty_msat(short_channel_id);
43 return impl_holder.held;
46 * Returns the fee in msats willing to be paid to avoid routing through the given channel.
48 public long channel_penalty_msat(long short_channel_id) {
49 long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id);