Trait lightning::ln::msgs::RoutingMessageHandler[][src]

pub trait RoutingMessageHandler: MessageSendEventsProvider {
    fn handle_node_announcement(
        &self,
        msg: &NodeAnnouncement
    ) -> Result<bool, LightningError>;
fn handle_channel_announcement(
        &self,
        msg: &ChannelAnnouncement
    ) -> Result<bool, LightningError>;
fn handle_channel_update(
        &self,
        msg: &ChannelUpdate
    ) -> Result<bool, LightningError>;
fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate);
fn get_next_channel_announcements(
        &self,
        starting_point: u64,
        batch_amount: u8
    ) -> Vec<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator
;
fn get_next_node_announcements(
        &self,
        starting_point: Option<&PublicKey>,
        batch_amount: u8
    ) -> Vec<NodeAnnouncement>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator
;
fn sync_routing_table(&self, their_node_id: &PublicKey, init: &Init);
fn handle_reply_channel_range(
        &self,
        their_node_id: &PublicKey,
        msg: ReplyChannelRange
    ) -> Result<(), LightningError>;
fn handle_reply_short_channel_ids_end(
        &self,
        their_node_id: &PublicKey,
        msg: ReplyShortChannelIdsEnd
    ) -> Result<(), LightningError>;
fn handle_query_channel_range(
        &self,
        their_node_id: &PublicKey,
        msg: QueryChannelRange
    ) -> Result<(), LightningError>;
fn handle_query_short_channel_ids(
        &self,
        their_node_id: &PublicKey,
        msg: QueryShortChannelIds
    ) -> Result<(), LightningError>; }
Expand description

A trait to describe an object which can receive routing messages.

Implementor DoS Warnings

For gossip_queries messages there are potential DoS vectors when handling inbound queries. Implementors using an on-disk network graph should be aware of repeated disk I/O for queries accessing different parts of the network graph.

Required methods

Handle an incoming node_announcement message, returning true if it should be forwarded on, false or returning an Err otherwise.

Handle a channel_announcement message, returning true if it should be forwarded on, false or returning an Err otherwise.

Handle an incoming channel_update message, returning true if it should be forwarded on, false or returning an Err otherwise.

Handle some updates to the route graph that we learned due to an outbound failed payment.

Gets a subset of the channel announcements and updates required to dump our routing table to a remote node, starting at the short_channel_id indicated by starting_point and including the batch_amount entries immediately higher in numerical value than starting_point.

Gets a subset of the node announcements required to dump our routing table to a remote node, starting at the node after the provided publickey and including batch_amount entries immediately higher (as defined by ::cmp) than starting_point. If None is provided for starting_point, we start at the first node.

Called when a connection is established with a peer. This can be used to perform routing table synchronization using a strategy defined by the implementor.

Handles the reply of a query we initiated to learn about channels for a given range of blocks. We can expect to receive one or more replies to a single query.

Handles the reply of a query we initiated asking for routing gossip messages for a list of channels. We should receive this message when a node has completed its best effort to send us the pertaining routing gossip messages.

Handles when a peer asks us to send a list of short_channel_ids for the requested range of blocks.

Handles when a peer asks us to send routing gossip messages for a list of short_channel_ids.

Implementors

Initiates a stateless sync of routing gossip information with a peer using gossip_queries. The default strategy used by this implementation is to sync the full block range with several peers.

We should expect one or more reply_channel_range messages in response to our query_channel_range. Each reply will enqueue a query_scid message to request gossip messages for each channel. The sync is considered complete when the final reply_scids_end message is received, though we are not tracking this directly.

Statelessly processes a reply to a channel range query by immediately sending an SCID query with SCIDs in the reply. To keep this handler stateless, it does not validate the sequencing of replies for multi- reply ranges. It does not validate whether the reply(ies) cover the queried range. It also does not filter SCIDs to only those in the original query range. We also do not validate that the chain_hash matches the chain_hash of the NetworkGraph. Any chan_ann message that does not match our chain_hash will be rejected when the announcement is processed.

When an SCID query is initiated the remote peer will begin streaming gossip messages. In the event of a failure, we may have received some channel information. Before trying with another peer, the caller should update its set of SCIDs that need to be queried.

Processes a query from a peer by finding announced/public channels whose funding UTXOs are in the specified block range. Due to message size limits, large range queries may result in several reply messages. This implementation enqueues all reply messages into pending events. Each message will allocate just under 65KiB. A full sync of the public routing table with 128k channels will generated 16 messages and allocate ~1MB. Logic can be changed to reduce allocation if/when a full sync of the routing table impacts memory constrained systems.