[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ScoreUpdate.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of ScoreUpdate */
12 public interface ScoreUpdateInterface {
13         /**Handles updating channel penalties after failing to route through a channel.
14          */
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.
17          */
18         void payment_path_successful(Path path, long duration_since_epoch);
19         /**Handles updating channel penalties after a probe over the given path failed.
20          */
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.
23          */
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).
29          */
30         void time_passed(long duration_since_epoch);
31 }
32
33 /**
34  * `ScoreUpdate` is used to update the scorer's internal state after a payment attempt.
35  */
36 public class ScoreUpdate : CommonBase {
37         internal bindings.LDKScoreUpdate bindings_instance;
38         internal long instance_idx;
39
40         internal ScoreUpdate(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
41         ~ScoreUpdate() {
42                 if (ptr != 0) { bindings.ScoreUpdate_free(ptr); }
43         }
44
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);
53                                 GC.KeepAlive(arg);
54                 }
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);
58                                 GC.KeepAlive(arg);
59                 }
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);
63                                 GC.KeepAlive(arg);
64                 }
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);
68                                 GC.KeepAlive(arg);
69                 }
70                 public void time_passed(long _duration_since_epoch) {
71                         arg.time_passed(_duration_since_epoch);
72                                 GC.KeepAlive(arg);
73                 }
74         }
75
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);
81
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;
86         }
87
88         /**
89          * Handles updating channel penalties after failing to route through a channel.
90          */
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 == null ? 0 : path.ptr, short_channel_id, duration_since_epoch);
93                 GC.KeepAlive(this);
94                 GC.KeepAlive(path);
95                 GC.KeepAlive(short_channel_id);
96                 GC.KeepAlive(duration_since_epoch);
97                 if (this != null) { this.ptrs_to.AddLast(path); };
98         }
99
100         /**
101          * Handles updating channel penalties after successfully routing along a path.
102          */
103         public void payment_path_successful(org.ldk.structs.Path path, long duration_since_epoch) {
104                 bindings.ScoreUpdate_payment_path_successful(this.ptr, path == null ? 0 : path.ptr, duration_since_epoch);
105                 GC.KeepAlive(this);
106                 GC.KeepAlive(path);
107                 GC.KeepAlive(duration_since_epoch);
108                 if (this != null) { this.ptrs_to.AddLast(path); };
109         }
110
111         /**
112          * Handles updating channel penalties after a probe over the given path failed.
113          */
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 == null ? 0 : path.ptr, short_channel_id, duration_since_epoch);
116                 GC.KeepAlive(this);
117                 GC.KeepAlive(path);
118                 GC.KeepAlive(short_channel_id);
119                 GC.KeepAlive(duration_since_epoch);
120                 if (this != null) { this.ptrs_to.AddLast(path); };
121         }
122
123         /**
124          * Handles updating channel penalties after a probe over the given path succeeded.
125          */
126         public void probe_successful(org.ldk.structs.Path path, long duration_since_epoch) {
127                 bindings.ScoreUpdate_probe_successful(this.ptr, path == null ? 0 : path.ptr, duration_since_epoch);
128                 GC.KeepAlive(this);
129                 GC.KeepAlive(path);
130                 GC.KeepAlive(duration_since_epoch);
131                 if (this != null) { this.ptrs_to.AddLast(path); };
132         }
133
134         /**
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).
139          */
140         public void time_passed(long duration_since_epoch) {
141                 bindings.ScoreUpdate_time_passed(this.ptr, duration_since_epoch);
142                 GC.KeepAlive(this);
143                 GC.KeepAlive(duration_since_epoch);
144         }
145
146 }
147 } } }