]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java
Merge pull request #107 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / ReadOnlyNetworkGraph.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 /**
12  * A read-only view of [`NetworkGraph`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ReadOnlyNetworkGraph extends CommonBase implements AutoCloseable {
16         ReadOnlyNetworkGraph(Object _dummy, long ptr) { super(ptr); }
17         @Override public void close() {
18                 if (ptr != 0) { bindings.ReadOnlyNetworkGraph_free(ptr); }
19         }
20
21         /**
22          * Get network addresses by node id.
23          * Returns None if the requested node is completely unknown,
24          * or if node announcement for the node was never received.
25          */
26         public Option_CVec_NetAddressZZ get_addresses(byte[] pubkey) {
27                 long ret = bindings.ReadOnlyNetworkGraph_get_addresses(this.ptr, InternalUtils.check_arr_len(pubkey, 33));
28                 Reference.reachabilityFence(this);
29                 Reference.reachabilityFence(pubkey);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.Option_CVec_NetAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_NetAddressZZ.constr_from_ptr(ret);
32                 ret_hu_conv.ptrs_to.add(this);
33                 return ret_hu_conv;
34         }
35
36 }