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 * The main Rapid Gossip Sync object.
14 * See [crate-level documentation] for usage.
16 * [crate-level documentation]: crate
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class RapidGossipSync extends CommonBase {
20 RapidGossipSync(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.RapidGossipSync_free(ptr); }
28 * Instantiate a new [`RapidGossipSync`] instance.
30 public static RapidGossipSync of(org.ldk.structs.NetworkGraph network_graph) {
31 long ret = bindings.RapidGossipSync_new(network_graph == null ? 0 : network_graph.ptr);
32 Reference.reachabilityFence(network_graph);
33 if (ret >= 0 && ret <= 4096) { return null; }
34 org.ldk.structs.RapidGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RapidGossipSync(null, ret); }
35 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
41 * Update network graph from binary data.
42 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
44 * `network_graph`: network graph to be updated
46 * `update_data`: `&[u8]` binary stream that comprises the update data
48 public Result_u32GraphSyncErrorZ update_network_graph(byte[] update_data) {
49 long ret = bindings.RapidGossipSync_update_network_graph(this.ptr, update_data);
50 Reference.reachabilityFence(this);
51 Reference.reachabilityFence(update_data);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
58 * Returns whether a rapid gossip sync has completed at least once.
60 public boolean is_initial_sync_complete() {
61 boolean ret = bindings.RapidGossipSync_is_initial_sync_complete(this.ptr);
62 Reference.reachabilityFence(this);