Trait BaseMessageHandler

Source
pub trait BaseMessageHandler {
    // Required methods
    fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent>;
    fn peer_disconnected(&self, their_node_id: PublicKey);
    fn provided_node_features(&self) -> NodeFeatures;
    fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures;
    fn peer_connected(
        &self,
        their_node_id: PublicKey,
        msg: &Init,
        inbound: bool,
    ) -> Result<(), ()>;
}
Expand description

A trait to describe an object which handles when peers connect + disconnect and generates outbound messages.

It acts as a supertrait for all the P2P message handlers and can contribute to the InitFeatures which we send to peers or decide to refuse connection to peers.

Required Methods§

Source

fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent>

Gets the list of pending events which were generated by previous actions, clearing the list in the process.

Source

fn peer_disconnected(&self, their_node_id: PublicKey)

Indicates a connection to the peer failed/an existing connection was lost.

Source

fn provided_node_features(&self) -> NodeFeatures

Gets the node feature flags which this handler itself supports. All available handlers are queried similarly and their feature flags are OR’d together to form the NodeFeatures which are broadcasted in our NodeAnnouncement message.

Source

fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures

Gets the init feature flags which should be sent to the given peer. All available handlers are queried similarly and their feature flags are OR’d together to form the InitFeatures which are sent in our Init message.

Note that this method is called before Self::peer_connected.

Source

fn peer_connected( &self, their_node_id: PublicKey, msg: &Init, inbound: bool, ) -> Result<(), ()>

Handle a peer (re)connecting.

May return an Err(()) to indicate that we should immediately disconnect from the peer (e.g. because the features they support are not sufficient to communicate with us).

Note, of course, that other message handlers may wish to communicate with the peer, which disconnecting them will prevent.

Self::peer_disconnected will not be called if Err(()) is returned.

Implementors§

Source§

impl BaseMessageHandler for ErroringMessageHandler

Source§

impl BaseMessageHandler for IgnoringMessageHandler

Source§

impl<ChannelSigner: EcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref, ES: Deref> BaseMessageHandler for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>

Source§

impl<ES: Deref, NS: Deref, L: Deref, NL: Deref, MR: Deref, OMH: Deref, APH: Deref, DRH: Deref, CMH: Deref> BaseMessageHandler for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>

Source§

impl<G: Deref<Target = NetworkGraph<L>>, U: Deref, L: Deref> BaseMessageHandler for P2PGossipSync<G, U, L>
where U::Target: UtxoLookup, L::Target: Logger,

Source§

impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref> BaseMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>