org.ldk.structs.P2PGossipSync Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ldk-java Show documentation
Show all versions of ldk-java Show documentation
LDK Java Bindings and Release Binaries
package org.ldk.structs;
import org.ldk.impl.bindings;
import org.ldk.enums.*;
import org.ldk.util.*;
import java.util.Arrays;
import java.lang.ref.Reference;
import javax.annotation.Nullable;
/**
* 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.
*/
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
public class P2PGossipSync extends CommonBase {
P2PGossipSync(Object _dummy, long ptr) { super(ptr); }
@Override @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
super.finalize();
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 [`NetworkGraph`].
* UTXO lookup is used to make sure announced channels exist on-chain, channel data is
* correct, and the announcement is signed with channel owners' keys.
*/
public static P2PGossipSync of(org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Option_UtxoLookupZ utxo_lookup, org.ldk.structs.Logger logger) {
long ret = bindings.P2PGossipSync_new(network_graph == null ? 0 : network_graph.ptr, utxo_lookup.ptr, logger.ptr);
Reference.reachabilityFence(network_graph);
Reference.reachabilityFence(utxo_lookup);
Reference.reachabilityFence(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.add(ret_hu_conv); };
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(utxo_lookup); };
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(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_utxo_lookup(org.ldk.structs.Option_UtxoLookupZ utxo_lookup) {
bindings.P2PGossipSync_add_utxo_lookup(this.ptr, utxo_lookup.ptr);
Reference.reachabilityFence(this);
Reference.reachabilityFence(utxo_lookup);
if (this != null) { this.ptrs_to.add(utxo_lookup); };
}
/**
* 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);
Reference.reachabilityFence(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.add(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);
Reference.reachabilityFence(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.add(this); };
return ret_hu_conv;
}
}