Trait reth_network_api::Peers

source ·
pub trait Peers: PeersInfo {
Show 19 methods // Required methods fn add_trusted_peer_id(&self, peer: PeerId); fn add_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, ); fn get_peers_by_kind( &self, kind: PeerKind, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send; fn get_all_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send; fn get_peer_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send; fn get_peers_by_id( &self, peer_ids: Vec<PeerId>, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send; fn remove_peer(&self, peer: PeerId, kind: PeerKind); fn disconnect_peer(&self, peer: PeerId); fn disconnect_peer_with_reason( &self, peer: PeerId, reason: DisconnectReason, ); fn connect_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, ); fn reputation_change(&self, peer_id: PeerId, kind: ReputationChangeKind); fn reputation_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<Reputation>, NetworkError>> + Send; // Provided methods fn add_peer(&self, peer: PeerId, tcp_addr: SocketAddr) { ... } fn add_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, ) { ... } fn add_trusted_peer(&self, peer: PeerId, tcp_addr: SocketAddr) { ... } fn add_trusted_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, ) { ... } fn get_trusted_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send { ... } fn get_basic_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send { ... } fn connect_peer(&self, peer: PeerId, tcp_addr: SocketAddr) { ... }
}
Expand description

Provides an API for managing the peers of the network.

Required Methods§

source

fn add_trusted_peer_id(&self, peer: PeerId)

Adds a trusted PeerId to the peer set.

This allows marking a peer as trusted without having to know the peer’s address.

source

fn add_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

Adds a peer to the known peer set, with the given kind.

source

fn get_peers_by_kind( &self, kind: PeerKind, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for all connected peers with the given kind.

source

fn get_all_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for all connected peers.

source

fn get_peer_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for the given peer id.

Returns None if the peer is not connected.

source

fn get_peers_by_id( &self, peer_ids: Vec<PeerId>, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for the given peers if they are connected.

Note: This only returns peers that are connected, unconnected peers are ignored but keeping the order in which they were requested.

source

fn remove_peer(&self, peer: PeerId, kind: PeerKind)

Removes a peer from the peer set that corresponds to given kind.

source

fn disconnect_peer(&self, peer: PeerId)

Disconnect an existing connection to the given peer.

source

fn disconnect_peer_with_reason(&self, peer: PeerId, reason: DisconnectReason)

Disconnect an existing connection to the given peer using the provided reason

source

fn connect_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

Connects a peer to the known peer set, with the given kind.

source

fn reputation_change(&self, peer_id: PeerId, kind: ReputationChangeKind)

Send a reputation change for the given peer.

source

fn reputation_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<Reputation>, NetworkError>> + Send

Get the reputation of a peer.

Provided Methods§

source

fn add_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

Adds a peer to the peer set with TCP SocketAddr.

source

fn add_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Adds a peer to the peer set with TCP and UDP SocketAddr.

source

fn add_trusted_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

Adds a trusted peer to the peer set with TCP SocketAddr.

source

fn add_trusted_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Adds a trusted peer with TCP and UDP SocketAddr to the peer set.

source

fn get_trusted_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for all connected PeerKind::Trusted peers.

source

fn get_basic_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

Returns the rpc PeerInfo for all connected PeerKind::Basic peers.

source

fn connect_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

Connect to the given peer. NOTE: if the maximum number out outbound sessions is reached, this won’t do anything. See reth_network::SessionManager::dial_outbound.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, T: 'a + Peers + ?Sized> Peers for &'a T

source§

fn add_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn add_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

source§

fn add_trusted_peer_id(&self, peer: PeerId)

source§

fn add_trusted_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn add_trusted_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

source§

fn add_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

source§

fn get_trusted_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_basic_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_peers_by_kind( &self, kind: PeerKind, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_all_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_peer_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send

source§

fn get_peers_by_id( &self, peer_ids: Vec<PeerId>, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn remove_peer(&self, peer: PeerId, kind: PeerKind)

source§

fn disconnect_peer(&self, peer: PeerId)

source§

fn disconnect_peer_with_reason(&self, peer: PeerId, reason: DisconnectReason)

source§

fn connect_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn connect_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

source§

fn reputation_change(&self, peer_id: PeerId, kind: ReputationChangeKind)

source§

fn reputation_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<Reputation>, NetworkError>> + Send

source§

impl<T: Peers + ?Sized> Peers for Arc<T>
where Arc<T>: PeersInfo,

source§

fn add_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn add_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

source§

fn add_trusted_peer_id(&self, peer: PeerId)

source§

fn add_trusted_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn add_trusted_peer_with_udp( &self, peer: PeerId, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

source§

fn add_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

source§

fn get_trusted_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_basic_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_peers_by_kind( &self, kind: PeerKind, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_all_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn get_peer_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send

source§

fn get_peers_by_id( &self, peer_ids: Vec<PeerId>, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send

source§

fn remove_peer(&self, peer: PeerId, kind: PeerKind)

source§

fn disconnect_peer(&self, peer: PeerId)

source§

fn disconnect_peer_with_reason(&self, peer: PeerId, reason: DisconnectReason)

source§

fn connect_peer(&self, peer: PeerId, tcp_addr: SocketAddr)

source§

fn connect_peer_kind( &self, peer: PeerId, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, )

source§

fn reputation_change(&self, peer_id: PeerId, kind: ReputationChangeKind)

source§

fn reputation_by_id( &self, peer_id: PeerId, ) -> impl Future<Output = Result<Option<Reputation>, NetworkError>> + Send

Implementors§