6 namespace org { namespace ldk { namespace structs {
10 * The main Rapid Gossip Sync object.
12 * See [crate-level documentation] for usage.
14 * [crate-level documentation]: crate
16 public class RapidGossipSync : CommonBase {
17 internal RapidGossipSync(object _dummy, long ptr) : base(ptr) { }
19 if (ptr != 0) { bindings.RapidGossipSync_free(ptr); }
23 * Instantiate a new [`RapidGossipSync`] instance.
25 public static RapidGossipSync of(org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Logger logger) {
26 long ret = bindings.RapidGossipSync_new(network_graph.ptr, logger.ptr);
27 GC.KeepAlive(network_graph);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.RapidGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RapidGossipSync(null, ret); }
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
32 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
38 * Sync gossip data from a file.
39 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
41 * `network_graph`: The network graph to apply the updates to
43 * `sync_path`: Path to the file where the gossip update data is located
45 public Result_u32GraphSyncErrorZ sync_network_graph_with_file_path(string sync_path) {
46 long ret = bindings.RapidGossipSync_sync_network_graph_with_file_path(this.ptr, InternalUtils.encodeString(sync_path));
48 GC.KeepAlive(sync_path);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
55 * Update network graph from binary data.
56 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
58 * `update_data`: `&[u8]` binary stream that comprises the update data
60 public Result_u32GraphSyncErrorZ update_network_graph(byte[] update_data) {
61 long ret = bindings.RapidGossipSync_update_network_graph(this.ptr, InternalUtils.encodeUint8Array(update_data));
63 GC.KeepAlive(update_data);
64 if (ret >= 0 && ret <= 4096) { return null; }
65 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
70 * Update network graph from binary data.
71 * Returns the last sync timestamp to be used the next time rapid sync data is queried.
73 * `update_data`: `&[u8]` binary stream that comprises the update data
74 * `current_time_unix`: `Option<u64>` optional current timestamp to verify data age
76 public Result_u32GraphSyncErrorZ update_network_graph_no_std(byte[] update_data, org.ldk.structs.Option_u64Z current_time_unix) {
77 long ret = bindings.RapidGossipSync_update_network_graph_no_std(this.ptr, InternalUtils.encodeUint8Array(update_data), current_time_unix.ptr);
79 GC.KeepAlive(update_data);
80 GC.KeepAlive(current_time_unix);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
83 if (this != null) { this.ptrs_to.AddLast(current_time_unix); };
88 * Returns whether a rapid gossip sync has completed at least once.
90 public bool is_initial_sync_complete() {
91 bool ret = bindings.RapidGossipSync_is_initial_sync_complete(this.ptr);