6f9f629e18b32b69757627595287b145cf70fa86
[ldk-java] / c_sharp / src / org / ldk / structs / ScorerAccountingForInFlightHtlcs.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * [`Score`] implementation that factors in in-flight HTLC liquidity.
11  * 
12  * Useful for custom [`Router`] implementations to wrap their [`Score`] on-the-fly when calling
13  * [`find_route`].
14  * 
15  * [`Score`]: crate::routing::scoring::Score
16  */
17 public class ScorerAccountingForInFlightHtlcs : CommonBase {
18         internal ScorerAccountingForInFlightHtlcs(object _dummy, long ptr) : base(ptr) { }
19         ~ScorerAccountingForInFlightHtlcs() {
20                 if (ptr != 0) { bindings.ScorerAccountingForInFlightHtlcs_free(ptr); }
21         }
22
23         /**
24          * Initialize a new `ScorerAccountingForInFlightHtlcs`.
25          */
26         public static ScorerAccountingForInFlightHtlcs of(org.ldk.structs.Score scorer, org.ldk.structs.InFlightHtlcs inflight_htlcs) {
27                 long ret = bindings.ScorerAccountingForInFlightHtlcs_new(scorer == null ? 0 : scorer.ptr, inflight_htlcs == null ? 0 : inflight_htlcs.ptr);
28                 GC.KeepAlive(scorer);
29                 GC.KeepAlive(inflight_htlcs);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.ScorerAccountingForInFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ScorerAccountingForInFlightHtlcs(null, ret); }
32                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(scorer); };
34                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(inflight_htlcs); };
35                 return ret_hu_conv;
36         }
37
38         /**
39          * Serialize the ScorerAccountingForInFlightHtlcs object into a byte array which can be read by ScorerAccountingForInFlightHtlcs_read
40          */
41         public byte[] write() {
42                 byte[] ret = bindings.ScorerAccountingForInFlightHtlcs_write(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * Constructs a new Score which calls the relevant methods on this_arg.
49          * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
50          */
51         public Score as_Score() {
52                 long ret = bindings.ScorerAccountingForInFlightHtlcs_as_Score(this.ptr);
53                 GC.KeepAlive(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 Score ret_hu_conv = new Score(null, ret);
56                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
57                 return ret_hu_conv;
58         }
59
60 }
61 } } }