using org.ldk.impl; using org.ldk.enums; using org.ldk.util; using System; namespace org { namespace ldk { namespace structs { /** * Receives and validates network updates from peers, * stores authentic and relevant data as a network graph. * This network graph is then used for routing payments. * Provides interface to help with initial routing sync by * serving historical announcements. */ public class P2PGossipSync : CommonBase { internal P2PGossipSync(object _dummy, long ptr) : base(ptr) { } ~P2PGossipSync() { if (ptr != 0) { bindings.P2PGossipSync_free(ptr); } } /** * Creates a new tracker of the actual state of the network of channels and nodes, * assuming an existing Network Graph. * Chain monitor is used to make sure announced channels exist on-chain, * channel data is correct, and that the announcement is signed with * channel owners' keys. */ public static P2PGossipSync of(org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Option_AccessZ chain_access, org.ldk.structs.Logger logger) { long ret = bindings.P2PGossipSync_new(network_graph == null ? 0 : network_graph.ptr, chain_access.ptr, logger == null ? 0 : logger.ptr); GC.KeepAlive(network_graph); GC.KeepAlive(chain_access); GC.KeepAlive(logger); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.P2PGossipSync ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.P2PGossipSync(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_access); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); }; return ret_hu_conv; } /** * Adds a provider used to check new announcements. Does not affect * existing announcements unless they are updated. * Add, update or remove the provider would replace the current one. */ public void add_chain_access(org.ldk.structs.Option_AccessZ chain_access) { bindings.P2PGossipSync_add_chain_access(this.ptr, chain_access.ptr); GC.KeepAlive(this); GC.KeepAlive(chain_access); if (this != null) { this.ptrs_to.AddLast(chain_access); }; } /** * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ public RoutingMessageHandler as_RoutingMessageHandler() { long ret = bindings.P2PGossipSync_as_RoutingMessageHandler(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; return ret_hu_conv; } /** * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ public MessageSendEventsProvider as_MessageSendEventsProvider() { long ret = bindings.P2PGossipSync_as_MessageSendEventsProvider(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; return ret_hu_conv; } } } } }