Trait reth_network::protocol::ConnectionHandler

source ·
pub trait ConnectionHandler:
    Send
    + Sync
    + 'static {
    type Connection: Stream<Item = BytesMut> + Send + 'static;

    // Required methods
    fn protocol(&self) -> Protocol;
    fn on_unsupported_by_peer(
        self,
        supported: &SharedCapabilities,
        direction: Direction,
        peer_id: PeerId,
    ) -> OnNotSupported;
    fn into_connection(
        self,
        direction: Direction,
        peer_id: PeerId,
        conn: ProtocolConnection,
    ) -> Self::Connection;
}
Expand description

A trait that allows to authenticate a protocol after the RLPx connection was established.

Required Associated Types§

source

type Connection: Stream<Item = BytesMut> + Send + 'static

The connection that yields messages to send to the remote.

The connection will be closed when this stream resolves.

Required Methods§

source

fn protocol(&self) -> Protocol

Returns the protocol to announce when the RLPx connection will be established.

This will be negotiated with the remote peer.

source

fn on_unsupported_by_peer( self, supported: &SharedCapabilities, direction: Direction, peer_id: PeerId, ) -> OnNotSupported

Invoked when the RLPx connection has been established by the peer does not share the protocol.

source

fn into_connection( self, direction: Direction, peer_id: PeerId, conn: ProtocolConnection, ) -> Self::Connection

Invoked when the RLPx connection was established.

The returned future should resolve when the connection should disconnect.

Implementors§