Merge pull request #124 from TheBlueMatt/main
[ldk-java] / c_sharp / src / org / ldk / structs / RapidGossipSync.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * The main Rapid Gossip Sync object.
11  * 
12  * See [crate-level documentation] for usage.
13  * 
14  * [crate-level documentation]: crate
15  */
16 public class RapidGossipSync : CommonBase {
17         internal RapidGossipSync(object _dummy, long ptr) : base(ptr) { }
18         ~RapidGossipSync() {
19                 if (ptr != 0) { bindings.RapidGossipSync_free(ptr); }
20         }
21
22         /**
23          * Instantiate a new [`RapidGossipSync`] instance.
24          */
25         public static RapidGossipSync of(org.ldk.structs.NetworkGraph network_graph) {
26                 long ret = bindings.RapidGossipSync_new(network_graph == null ? 0 : network_graph.ptr);
27                 GC.KeepAlive(network_graph);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 org.ldk.structs.RapidGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RapidGossipSync(null, ret); }
30                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * Update network graph from binary data.
37          * Returns the last sync timestamp to be used the next time rapid sync data is queried.
38          * 
39          * `network_graph`: network graph to be updated
40          * 
41          * `update_data`: `&[u8]` binary stream that comprises the update data
42          */
43         public Result_u32GraphSyncErrorZ update_network_graph(byte[] update_data) {
44                 long ret = bindings.RapidGossipSync_update_network_graph(this.ptr, update_data);
45                 GC.KeepAlive(this);
46                 GC.KeepAlive(update_data);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 Result_u32GraphSyncErrorZ ret_hu_conv = Result_u32GraphSyncErrorZ.constr_from_ptr(ret);
49                 return ret_hu_conv;
50         }
51
52         /**
53          * Returns whether a rapid gossip sync has completed at least once.
54          */
55         public bool is_initial_sync_complete() {
56                 bool ret = bindings.RapidGossipSync_is_initial_sync_complete(this.ptr);
57                 GC.KeepAlive(this);
58                 return ret;
59         }
60
61 }
62 } } }