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, long duration_since_epoch);
16 /**Handles updating channel penalties after successfully routing along a path.
18 void payment_path_successful(Path path, long duration_since_epoch);
19 /**Handles updating channel penalties after a probe over the given path failed.
21 void probe_failed(Path path, long short_channel_id, long duration_since_epoch);
22 /**Handles updating channel penalties after a probe over the given path succeeded.
24 void probe_successful(Path path, long duration_since_epoch);
25 /**Scorers may wish to reduce their certainty of channel liquidity information over time.
26 * Thus, this method is provided to allow scorers to observe the passage of time - the holder
27 * of this object should call this method regularly (generally via the
28 * `lightning-background-processor` crate).
30 void time_passed(long duration_since_epoch);
34 * `ScoreUpdate` is used to update the scorer's internal state after a payment attempt.
36 public class ScoreUpdate : CommonBase {
37 internal bindings.LDKScoreUpdate bindings_instance;
38 internal long instance_idx;
40 internal ScoreUpdate(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
42 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); }
45 private class LDKScoreUpdateHolder { internal ScoreUpdate held; }
46 private class LDKScoreUpdateImpl : bindings.LDKScoreUpdate {
47 internal LDKScoreUpdateImpl(ScoreUpdateInterface arg, LDKScoreUpdateHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
48 private ScoreUpdateInterface arg;
49 private LDKScoreUpdateHolder impl_holder;
50 public void payment_path_failed(long _path, long _short_channel_id, long _duration_since_epoch) {
51 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
52 arg.payment_path_failed(_path_hu_conv, _short_channel_id, _duration_since_epoch);
55 public void payment_path_successful(long _path, long _duration_since_epoch) {
56 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
57 arg.payment_path_successful(_path_hu_conv, _duration_since_epoch);
60 public void probe_failed(long _path, long _short_channel_id, long _duration_since_epoch) {
61 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
62 arg.probe_failed(_path_hu_conv, _short_channel_id, _duration_since_epoch);
65 public void probe_successful(long _path, long _duration_since_epoch) {
66 org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
67 arg.probe_successful(_path_hu_conv, _duration_since_epoch);
70 public void time_passed(long _duration_since_epoch) {
71 arg.time_passed(_duration_since_epoch);
76 /** Creates a new instance of ScoreUpdate from a given implementation */
77 public static ScoreUpdate new_impl(ScoreUpdateInterface arg) {
78 LDKScoreUpdateHolder impl_holder = new LDKScoreUpdateHolder();
79 LDKScoreUpdateImpl impl = new LDKScoreUpdateImpl(arg, impl_holder);
80 long[] ptr_idx = bindings.LDKScoreUpdate_new(impl);
82 impl_holder.held = new ScoreUpdate(null, ptr_idx[0]);
83 impl_holder.held.instance_idx = ptr_idx[1];
84 impl_holder.held.bindings_instance = impl;
85 return impl_holder.held;
89 * Handles updating channel penalties after failing to route through a channel.
91 public void payment_path_failed(org.ldk.structs.Path path, long short_channel_id, long duration_since_epoch) {
92 bindings.ScoreUpdate_payment_path_failed(this.ptr, path.ptr, short_channel_id, duration_since_epoch);
95 GC.KeepAlive(short_channel_id);
96 GC.KeepAlive(duration_since_epoch);
97 if (this != null) { this.ptrs_to.AddLast(path); };
101 * Handles updating channel penalties after successfully routing along a path.
103 public void payment_path_successful(org.ldk.structs.Path path, long duration_since_epoch) {
104 bindings.ScoreUpdate_payment_path_successful(this.ptr, path.ptr, duration_since_epoch);
107 GC.KeepAlive(duration_since_epoch);
108 if (this != null) { this.ptrs_to.AddLast(path); };
112 * Handles updating channel penalties after a probe over the given path failed.
114 public void probe_failed(org.ldk.structs.Path path, long short_channel_id, long duration_since_epoch) {
115 bindings.ScoreUpdate_probe_failed(this.ptr, path.ptr, short_channel_id, duration_since_epoch);
118 GC.KeepAlive(short_channel_id);
119 GC.KeepAlive(duration_since_epoch);
120 if (this != null) { this.ptrs_to.AddLast(path); };
124 * Handles updating channel penalties after a probe over the given path succeeded.
126 public void probe_successful(org.ldk.structs.Path path, long duration_since_epoch) {
127 bindings.ScoreUpdate_probe_successful(this.ptr, path.ptr, duration_since_epoch);
130 GC.KeepAlive(duration_since_epoch);
131 if (this != null) { this.ptrs_to.AddLast(path); };
135 * Scorers may wish to reduce their certainty of channel liquidity information over time.
136 * Thus, this method is provided to allow scorers to observe the passage of time - the holder
137 * of this object should call this method regularly (generally via the
138 * `lightning-background-processor` crate).
140 public void time_passed(long duration_since_epoch) {
141 bindings.ScoreUpdate_time_passed(this.ptr, duration_since_epoch);
143 GC.KeepAlive(duration_since_epoch);