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, org.ldk.structs.Logger logger) {
31 long ret = bindings.RapidGossipSync_new(network_graph.ptr, logger.ptr);
32 Reference.reachabilityFence(network_graph);
33 Reference.reachabilityFence(logger);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 org.ldk.structs.RapidGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RapidGossipSync(null, ret); }
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
37 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
43 * Sync gossip data from a file.
44 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
46 * `network_graph`: The network graph to apply the updates to
48 * `sync_path`: Path to the file where the gossip update data is located
50 public Result_u32GraphSyncErrorZ sync_network_graph_with_file_path(java.lang.String sync_path) {
51 long ret = bindings.RapidGossipSync_sync_network_graph_with_file_path(this.ptr, sync_path);
52 Reference.reachabilityFence(this);
53 Reference.reachabilityFence(sync_path);
54 if (ret >= 0 && ret <= 4096) { return null; }
55 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
60 * Update network graph from binary data.
61 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
63 * `update_data`: `&[u8]` binary stream that comprises the update data
65 public Result_u32GraphSyncErrorZ update_network_graph(byte[] update_data) {
66 long ret = bindings.RapidGossipSync_update_network_graph(this.ptr, update_data);
67 Reference.reachabilityFence(this);
68 Reference.reachabilityFence(update_data);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
75 * Update network graph from binary data.
76 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
78 * `update_data`: `&[u8]` binary stream that comprises the update data
79 * `current_time_unix`: `Option<u64>` optional current timestamp to verify data age
81 public Result_u32GraphSyncErrorZ update_network_graph_no_std(byte[] update_data, org.ldk.structs.Option_u64Z current_time_unix) {
82 long ret = bindings.RapidGossipSync_update_network_graph_no_std(this.ptr, update_data, current_time_unix.ptr);
83 Reference.reachabilityFence(this);
84 Reference.reachabilityFence(update_data);
85 Reference.reachabilityFence(current_time_unix);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
88 if (this != null) { this.ptrs_to.add(current_time_unix); };
93 * Returns whether a rapid gossip sync has completed at least once.
95 public boolean is_initial_sync_complete() {
96 boolean ret = bindings.RapidGossipSync_is_initial_sync_complete(this.ptr);
97 Reference.reachabilityFence(this);