7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of ScoreUpdate */
12 public interface ScoreUpdateInterface {
13 /**Handles updating channel penalties after failing to route through a channel.
15 void payment_path_failed(Path path, long short_channel_id);
16 /**Handles updating channel penalties after successfully routing along a path.
18 void payment_path_successful(Path path);
19 /**Handles updating channel penalties after a probe over the given path failed.
21 void probe_failed(Path path, long short_channel_id);
22 /**Handles updating channel penalties after a probe over the given path succeeded.
24 void probe_successful(Path path);
28 * `ScoreUpdate` is used to update the scorer's internal state after a payment attempt.
30 public class ScoreUpdate : CommonBase {
31 internal bindings.LDKScoreUpdate bindings_instance;
32 internal long instance_idx;
34 internal ScoreUpdate(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
36 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); }
39 private class LDKScoreUpdateHolder { internal ScoreUpdate held; }
40 private class LDKScoreUpdateImpl : bindings.LDKScoreUpdate {
41 internal LDKScoreUpdateImpl(ScoreUpdateInterface arg, LDKScoreUpdateHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
42 private ScoreUpdateInterface arg;
43 private LDKScoreUpdateHolder impl_holder;
44 public void payment_path_failed(long _path, long _short_channel_id) {
45 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
46 arg.payment_path_failed(_path_hu_conv, _short_channel_id);
49 public void payment_path_successful(long _path) {
50 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
51 arg.payment_path_successful(_path_hu_conv);
54 public void probe_failed(long _path, long _short_channel_id) {
55 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
56 arg.probe_failed(_path_hu_conv, _short_channel_id);
59 public void probe_successful(long _path) {
60 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
61 arg.probe_successful(_path_hu_conv);
66 /** Creates a new instance of ScoreUpdate from a given implementation */
67 public static ScoreUpdate new_impl(ScoreUpdateInterface arg) {
68 LDKScoreUpdateHolder impl_holder = new LDKScoreUpdateHolder();
69 LDKScoreUpdateImpl impl = new LDKScoreUpdateImpl(arg, impl_holder);
70 long[] ptr_idx = bindings.LDKScoreUpdate_new(impl);
72 impl_holder.held = new ScoreUpdate(null, ptr_idx[0]);
73 impl_holder.held.instance_idx = ptr_idx[1];
74 impl_holder.held.bindings_instance = impl;
75 return impl_holder.held;
79 * Handles updating channel penalties after failing to route through a channel.
81 public void payment_path_failed(org.ldk.structs.Path path, long short_channel_id) {
82 bindings.ScoreUpdate_payment_path_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
85 GC.KeepAlive(short_channel_id);
86 if (this != null) { this.ptrs_to.AddLast(path); };
90 * Handles updating channel penalties after successfully routing along a path.
92 public void payment_path_successful(org.ldk.structs.Path path) {
93 bindings.ScoreUpdate_payment_path_successful(this.ptr, path == null ? 0 : path.ptr);
96 if (this != null) { this.ptrs_to.AddLast(path); };
100 * Handles updating channel penalties after a probe over the given path failed.
102 public void probe_failed(org.ldk.structs.Path path, long short_channel_id) {
103 bindings.ScoreUpdate_probe_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
106 GC.KeepAlive(short_channel_id);
107 if (this != null) { this.ptrs_to.AddLast(path); };
111 * Handles updating channel penalties after a probe over the given path succeeded.
113 public void probe_successful(org.ldk.structs.Path path) {
114 bindings.ScoreUpdate_probe_successful(this.ptr, path == null ? 0 : path.ptr);
117 if (this != null) { this.ptrs_to.AddLast(path); };