]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/Access.java
Fix race in tests
[ldk-java] / src / main / java / org / ldk / structs / Access.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
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Access extends CommonBase {
10         final bindings.LDKAccess bindings_instance;
11         Access(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private Access(bindings.LDKAccess arg) {
13                 super(bindings.LDKAccess_new(arg));
14                 this.ptrs_to.add(arg);
15                 this.bindings_instance = arg;
16         }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 if (ptr != 0) { bindings.Access_free(ptr); } super.finalize();
20         }
21
22         public static interface AccessInterface {
23                 Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id);
24         }
25         private static class LDKAccessHolder { Access held; }
26         public static Access new_impl(AccessInterface arg) {
27                 final LDKAccessHolder impl_holder = new LDKAccessHolder();
28                 impl_holder.held = new Access(new bindings.LDKAccess() {
29                         @Override public long get_utxo(byte[] genesis_hash, long short_channel_id) {
30                                 Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id);
31                                 long result = ret != null ? ret.ptr : 0;
32                                 ret.ptr = 0;
33                                 return result;
34                         }
35                 });
36                 return impl_holder.held;
37         }
38         public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
39                 long ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
40                 Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
41                 ret_hu_conv.ptrs_to.add(this);
42                 return ret_hu_conv;
43         }
44
45 }