[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ScoreUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * `ScoreUpdate` is used to update the scorer's internal state after a payment attempt.
12  */
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;
21         }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); } super.finalize();
25         }
26         /**
27          * Destroys the object, freeing associated resources. After this call, any access
28          * to this object may result in a SEGFAULT or worse.
29          *
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
33          * until the GC runs.
34          */
35         public void destroy() {
36                 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); }
37                 ptr = 0;
38         }
39         public static interface ScoreUpdateInterface {
40                 /**
41                  * Handles updating channel penalties after failing to route through a channel.
42                  */
43                 void payment_path_failed(Path path, long short_channel_id, long duration_since_epoch);
44                 /**
45                  * Handles updating channel penalties after successfully routing along a path.
46                  */
47                 void payment_path_successful(Path path, long duration_since_epoch);
48                 /**
49                  * Handles updating channel penalties after a probe over the given path failed.
50                  */
51                 void probe_failed(Path path, long short_channel_id, long duration_since_epoch);
52                 /**
53                  * Handles updating channel penalties after a probe over the given path succeeded.
54                  */
55                 void probe_successful(Path path, long duration_since_epoch);
56                 /**
57                  * Scorers may wish to reduce their certainty of channel liquidity information over time.
58                  * Thus, this method is provided to allow scorers to observe the passage of time - the holder
59                  * of this object should call this method regularly (generally via the
60                  * `lightning-background-processor` crate).
61                  */
62                 void time_passed(long duration_since_epoch);
63         }
64         private static class LDKScoreUpdateHolder { ScoreUpdate held; }
65         public static ScoreUpdate new_impl(ScoreUpdateInterface arg) {
66                 final LDKScoreUpdateHolder impl_holder = new LDKScoreUpdateHolder();
67                 impl_holder.held = new ScoreUpdate(new bindings.LDKScoreUpdate() {
68                         @Override public void payment_path_failed(long path, long short_channel_id, long duration_since_epoch) {
69                                 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
70                                 arg.payment_path_failed(path_hu_conv, short_channel_id, duration_since_epoch);
71                                 Reference.reachabilityFence(arg);
72                         }
73                         @Override public void payment_path_successful(long path, long duration_since_epoch) {
74                                 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
75                                 arg.payment_path_successful(path_hu_conv, duration_since_epoch);
76                                 Reference.reachabilityFence(arg);
77                         }
78                         @Override public void probe_failed(long path, long short_channel_id, long duration_since_epoch) {
79                                 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
80                                 arg.probe_failed(path_hu_conv, short_channel_id, duration_since_epoch);
81                                 Reference.reachabilityFence(arg);
82                         }
83                         @Override public void probe_successful(long path, long duration_since_epoch) {
84                                 org.ldk.structs.Path path_hu_conv = null; if (path < 0 || path > 4096) { path_hu_conv = new org.ldk.structs.Path(null, path); }
85                                 arg.probe_successful(path_hu_conv, duration_since_epoch);
86                                 Reference.reachabilityFence(arg);
87                         }
88                         @Override public void time_passed(long duration_since_epoch) {
89                                 arg.time_passed(duration_since_epoch);
90                                 Reference.reachabilityFence(arg);
91                         }
92                 });
93                 return impl_holder.held;
94         }
95         /**
96          * Handles updating channel penalties after failing to route through a channel.
97          */
98         public void payment_path_failed(org.ldk.structs.Path path, long short_channel_id, long duration_since_epoch) {
99                 bindings.ScoreUpdate_payment_path_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id, duration_since_epoch);
100                 Reference.reachabilityFence(this);
101                 Reference.reachabilityFence(path);
102                 Reference.reachabilityFence(short_channel_id);
103                 Reference.reachabilityFence(duration_since_epoch);
104                 if (this != null) { this.ptrs_to.add(path); };
105         }
106
107         /**
108          * Handles updating channel penalties after successfully routing along a path.
109          */
110         public void payment_path_successful(org.ldk.structs.Path path, long duration_since_epoch) {
111                 bindings.ScoreUpdate_payment_path_successful(this.ptr, path == null ? 0 : path.ptr, duration_since_epoch);
112                 Reference.reachabilityFence(this);
113                 Reference.reachabilityFence(path);
114                 Reference.reachabilityFence(duration_since_epoch);
115                 if (this != null) { this.ptrs_to.add(path); };
116         }
117
118         /**
119          * Handles updating channel penalties after a probe over the given path failed.
120          */
121         public void probe_failed(org.ldk.structs.Path path, long short_channel_id, long duration_since_epoch) {
122                 bindings.ScoreUpdate_probe_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id, duration_since_epoch);
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(path);
125                 Reference.reachabilityFence(short_channel_id);
126                 Reference.reachabilityFence(duration_since_epoch);
127                 if (this != null) { this.ptrs_to.add(path); };
128         }
129
130         /**
131          * Handles updating channel penalties after a probe over the given path succeeded.
132          */
133         public void probe_successful(org.ldk.structs.Path path, long duration_since_epoch) {
134                 bindings.ScoreUpdate_probe_successful(this.ptr, path == null ? 0 : path.ptr, duration_since_epoch);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(path);
137                 Reference.reachabilityFence(duration_since_epoch);
138                 if (this != null) { this.ptrs_to.add(path); };
139         }
140
141         /**
142          * Scorers may wish to reduce their certainty of channel liquidity information over time.
143          * Thus, this method is provided to allow scorers to observe the passage of time - the holder
144          * of this object should call this method regularly (generally via the
145          * `lightning-background-processor` crate).
146          */
147         public void time_passed(long duration_since_epoch) {
148                 bindings.ScoreUpdate_time_passed(this.ptr, duration_since_epoch);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(duration_since_epoch);
151         }
152
153 }