1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Rapid Gossip Sync struct
13 * See [crate-level documentation] for usage.
15 * [crate-level documentation]: crate
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class RapidGossipSync extends CommonBase {
19 RapidGossipSync(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.RapidGossipSync_free(ptr); }
27 * Instantiate a new [`RapidGossipSync`] instance
29 public static RapidGossipSync of(NetworkGraph network_graph) {
30 long ret = bindings.RapidGossipSync_new(network_graph == null ? 0 : network_graph.ptr);
31 Reference.reachabilityFence(network_graph);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 org.ldk.structs.RapidGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RapidGossipSync(null, ret); }
34 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
35 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
40 * Sync gossip data from a file
41 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
43 * `network_graph`: The network graph to apply the updates to
45 * `sync_path`: Path to the file where the gossip update data is located
47 public Result_u32GraphSyncErrorZ sync_network_graph_with_file_path(java.lang.String sync_path) {
48 long ret = bindings.RapidGossipSync_sync_network_graph_with_file_path(this.ptr, sync_path);
49 Reference.reachabilityFence(this);
50 Reference.reachabilityFence(sync_path);
51 if (ret >= 0 && ret <= 4096) { return null; }
52 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
57 * Returns whether a rapid gossip sync has completed at least once
59 public boolean is_initial_sync_complete() {
60 boolean ret = bindings.RapidGossipSync_is_initial_sync_complete(this.ptr);
61 Reference.reachabilityFence(this);
66 * Update network graph from binary data.
67 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
69 * `network_graph`: network graph to be updated
71 * `update_data`: `&[u8]` binary stream that comprises the update data
73 public Result_u32GraphSyncErrorZ update_network_graph(byte[] update_data) {
74 long ret = bindings.RapidGossipSync_update_network_graph(this.ptr, update_data);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(update_data);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);