Package org.ldk.structs
Class NetworkGraph
- java.lang.Object
-
- org.ldk.structs.NetworkGraph
-
public class NetworkGraph extends Object
Represents the network as nodes and channels between them
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NetworkGraphclone()Creates a copy of the NetworkGraphvoidclose_channel_from_update(long short_channel_id, boolean is_permanent)Close a channel if a corresponding HTLC fail was sent.voidfail_node(byte[] _node_id, boolean is_permanent)Marks a node in the graph as failed.protected voidfinalize()static NetworkGraphof(byte[] genesis_hash)Creates a new, empty, network graph.static Result_NetworkGraphDecodeErrorZread(byte[] ser)Read a NetworkGraph from a byte array, created by NetworkGraph_writeReadOnlyNetworkGraphread_only()Returns a read-only view of the network graph.voidremove_stale_channels_with_time(long current_time_unix)Removes information about channels that we haven't heard any updates about in some time.Result_NoneLightningErrorZupdate_channel(ChannelUpdate msg)For an already known (from announcement) channel, update info about one of the directions of the channel.Result_NoneLightningErrorZupdate_channel_from_announcement(ChannelAnnouncement msg, Option_AccessZ chain_access)Store or update channel info from a channel announcement.Result_NoneLightningErrorZupdate_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Option_AccessZ chain_access)Store or update channel info from a channel announcement without verifying the associated signatures.Result_NoneLightningErrorZupdate_channel_unsigned(UnsignedChannelUpdate msg)For an already known (from announcement) channel, update info about one of the directions of the channel without verifying the associated signatures.Result_NoneLightningErrorZupdate_node_from_announcement(NodeAnnouncement msg)For an already known node (from channel announcements), update its stored properties from a given node announcement.Result_NoneLightningErrorZupdate_node_from_unsigned_announcement(UnsignedNodeAnnouncement msg)For an already known node (from channel announcements), update its stored properties from a given node announcement without verifying the associated signatures.byte[]write()Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
clone
public NetworkGraph clone()
Creates a copy of the NetworkGraph
-
write
public byte[] write()
Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
-
read
public static Result_NetworkGraphDecodeErrorZ read(byte[] ser)
Read a NetworkGraph from a byte array, created by NetworkGraph_write
-
of
public static NetworkGraph of(byte[] genesis_hash)
Creates a new, empty, network graph.
-
read_only
public ReadOnlyNetworkGraph read_only()
Returns a read-only view of the network graph.
-
update_node_from_announcement
public Result_NoneLightningErrorZ update_node_from_announcement(NodeAnnouncement msg)
For an already known node (from channel announcements), update its stored properties from a given node announcement. You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's RoutingMessageHandler implementation to call it indirectly. This may be useful to accept routing messages from a source using a protocol other than the lightning P2P protocol.
-
update_node_from_unsigned_announcement
public Result_NoneLightningErrorZ update_node_from_unsigned_announcement(UnsignedNodeAnnouncement msg)
For an already known node (from channel announcements), update its stored properties from a given node announcement without verifying the associated signatures. Because we aren't given the associated signatures here we cannot relay the node announcement to any of our peers.
-
update_channel_from_announcement
public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, Option_AccessZ chain_access)
Store or update channel info from a channel announcement. You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's RoutingMessageHandler implementation to call it indirectly. This may be useful to accept routing messages from a source using a protocol other than the lightning P2P protocol. If a `chain::Access` object is provided via `chain_access`, it will be called to verify the corresponding UTXO exists on chain and is correctly-formatted.
-
update_channel_from_unsigned_announcement
public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Option_AccessZ chain_access)
Store or update channel info from a channel announcement without verifying the associated signatures. Because we aren't given the associated signatures here we cannot relay the channel announcement to any of our peers. If a `chain::Access` object is provided via `chain_access`, it will be called to verify the corresponding UTXO exists on chain and is correctly-formatted.
-
close_channel_from_update
public void close_channel_from_update(long short_channel_id, boolean is_permanent)Close a channel if a corresponding HTLC fail was sent. If permanent, removes a channel from the local storage. May cause the removal of nodes too, if this was their last channel. If not permanent, makes channels unavailable for routing.
-
fail_node
public void fail_node(byte[] _node_id, boolean is_permanent)Marks a node in the graph as failed.
-
remove_stale_channels_with_time
public void remove_stale_channels_with_time(long current_time_unix)
Removes information about channels that we haven't heard any updates about in some time. This can be used regularly to prune the network graph of channels that likely no longer exist. While there is no formal requirement that nodes regularly re-broadcast their channel updates every two weeks, the non-normative section of BOLT 7 currently suggests that pruning occur for updates which are at least two weeks old, which we implement here. This function takes the current unix time as an argument. For users with the `std` feature enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
-
update_channel
public Result_NoneLightningErrorZ update_channel(ChannelUpdate msg)
For an already known (from announcement) channel, update info about one of the directions of the channel. You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's RoutingMessageHandler implementation to call it indirectly. This may be useful to accept routing messages from a source using a protocol other than the lightning P2P protocol. If built with `no-std`, any updates with a timestamp more than two weeks in the past or materially in the future will be rejected.
-
update_channel_unsigned
public Result_NoneLightningErrorZ update_channel_unsigned(UnsignedChannelUpdate msg)
For an already known (from announcement) channel, update info about one of the directions of the channel without verifying the associated signatures. Because we aren't given the associated signatures here we cannot relay the channel update to any of our peers. If built with `no-std`, any updates with a timestamp more than two weeks in the past or materially in the future will be rejected.
-
-