6 namespace org { namespace ldk { namespace structs {
10 * Receives and validates network updates from peers,
11 * stores authentic and relevant data as a network graph.
12 * This network graph is then used for routing payments.
13 * Provides interface to help with initial routing sync by
14 * serving historical announcements.
16 public class P2PGossipSync : CommonBase {
17 internal P2PGossipSync(object _dummy, long ptr) : base(ptr) { }
19 if (ptr != 0) { bindings.P2PGossipSync_free(ptr); }
23 * Creates a new tracker of the actual state of the network of channels and nodes,
24 * assuming an existing Network Graph.
25 * Chain monitor is used to make sure announced channels exist on-chain,
26 * channel data is correct, and that the announcement is signed with
27 * channel owners' keys.
29 public static P2PGossipSync of(org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Option_AccessZ chain_access, org.ldk.structs.Logger logger) {
30 long ret = bindings.P2PGossipSync_new(network_graph == null ? 0 : network_graph.ptr, chain_access.ptr, logger == null ? 0 : logger.ptr);
31 GC.KeepAlive(network_graph);
32 GC.KeepAlive(chain_access);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 org.ldk.structs.P2PGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.P2PGossipSync(null, ret); }
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
37 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_access); };
39 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
44 * Adds a provider used to check new announcements. Does not affect
45 * existing announcements unless they are updated.
46 * Add, update or remove the provider would replace the current one.
48 public void add_chain_access(org.ldk.structs.Option_AccessZ chain_access) {
49 bindings.P2PGossipSync_add_chain_access(this.ptr, chain_access.ptr);
51 GC.KeepAlive(chain_access);
52 if (this != null) { this.ptrs_to.AddLast(chain_access); };
56 * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
57 * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
59 public RoutingMessageHandler as_RoutingMessageHandler() {
60 long ret = bindings.P2PGossipSync_as_RoutingMessageHandler(this.ptr);
62 if (ret >= 0 && ret <= 4096) { return null; }
63 RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
64 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
69 * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
70 * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
72 public MessageSendEventsProvider as_MessageSendEventsProvider() {
73 long ret = bindings.P2PGossipSync_as_MessageSendEventsProvider(this.ptr);
75 if (ret >= 0 && ret <= 4096) { return null; }
76 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
77 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };