1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
11 * `ScoreUpdate` is used to update the scorer's internal state after a payment attempt.
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ScoreUpdate extends CommonBase {
15 final bindings.LDKScoreUpdate bindings_instance;
16 ScoreUpdate(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
17 private ScoreUpdate(bindings.LDKScoreUpdate arg) {
18 super(bindings.LDKScoreUpdate_new(arg));
19 this.ptrs_to.add(arg);
20 this.bindings_instance = arg;
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); } super.finalize();
27 * Destroys the object, freeing associated resources. After this call, any access
28 * to this object may result in a SEGFAULT or worse.
30 * You should generally NEVER call this method. You should let the garbage collector
31 * do this for you when it finalizes objects. However, it may be useful for types
32 * which represent locks and should be closed immediately to avoid holding locks
35 public void destroy() {
36 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); }
39 public static interface ScoreUpdateInterface {
41 * Handles updating channel penalties after failing to route through a channel.
43 void payment_path_failed(Path path, long short_channel_id);
45 * Handles updating channel penalties after successfully routing along a path.
47 void payment_path_successful(Path path);
49 * Handles updating channel penalties after a probe over the given path failed.
51 void probe_failed(Path path, long short_channel_id);
53 * Handles updating channel penalties after a probe over the given path succeeded.
55 void probe_successful(Path path);
57 private static class LDKScoreUpdateHolder { ScoreUpdate held; }
58 public static ScoreUpdate new_impl(ScoreUpdateInterface arg) {
59 final LDKScoreUpdateHolder impl_holder = new LDKScoreUpdateHolder();
60 impl_holder.held = new ScoreUpdate(new bindings.LDKScoreUpdate() {
61 @Override public void payment_path_failed(long path, long short_channel_id) {
62 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
63 arg.payment_path_failed(path_hu_conv, short_channel_id);
64 Reference.reachabilityFence(arg);
66 @Override public void payment_path_successful(long path) {
67 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
68 arg.payment_path_successful(path_hu_conv);
69 Reference.reachabilityFence(arg);
71 @Override public void probe_failed(long path, long short_channel_id) {
72 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
73 arg.probe_failed(path_hu_conv, short_channel_id);
74 Reference.reachabilityFence(arg);
76 @Override public void probe_successful(long path) {
77 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
78 arg.probe_successful(path_hu_conv);
79 Reference.reachabilityFence(arg);
82 return impl_holder.held;
85 * Handles updating channel penalties after failing to route through a channel.
87 public void payment_path_failed(org.ldk.structs.Path path, long short_channel_id) {
88 bindings.ScoreUpdate_payment_path_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
89 Reference.reachabilityFence(this);
90 Reference.reachabilityFence(path);
91 Reference.reachabilityFence(short_channel_id);
92 if (this != null) { this.ptrs_to.add(path); };
96 * Handles updating channel penalties after successfully routing along a path.
98 public void payment_path_successful(org.ldk.structs.Path path) {
99 bindings.ScoreUpdate_payment_path_successful(this.ptr, path == null ? 0 : path.ptr);
100 Reference.reachabilityFence(this);
101 Reference.reachabilityFence(path);
102 if (this != null) { this.ptrs_to.add(path); };
106 * Handles updating channel penalties after a probe over the given path failed.
108 public void probe_failed(org.ldk.structs.Path path, long short_channel_id) {
109 bindings.ScoreUpdate_probe_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
110 Reference.reachabilityFence(this);
111 Reference.reachabilityFence(path);
112 Reference.reachabilityFence(short_channel_id);
113 if (this != null) { this.ptrs_to.add(path); };
117 * Handles updating channel penalties after a probe over the given path succeeded.
119 public void probe_successful(org.ldk.structs.Path path) {
120 bindings.ScoreUpdate_probe_successful(this.ptr, path == null ? 0 : path.ptr);
121 Reference.reachabilityFence(this);
122 Reference.reachabilityFence(path);
123 if (this != null) { this.ptrs_to.add(path); };