reth::network

Trait Peers

Source
pub trait Peers: PeersInfo {
Show 19 methods // Required methods fn add_trusted_peer_id(&self, peer: FixedBytes<64>); fn add_peer_kind( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send; fn get_peers_by_id( &self, peer_ids: Vec<FixedBytes<64>>, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send; fn remove_peer(&self, peer: FixedBytes<64>, kind: PeerKind); fn disconnect_peer(&self, peer: FixedBytes<64>); fn disconnect_peer_with_reason( &self, peer: FixedBytes<64>, reason: DisconnectReason, ); fn connect_peer_kind( &self, peer: FixedBytes<64>, kind: PeerKind, tcp_addr: SocketAddr, udp_addr: Option<SocketAddr>, ); fn reputation_change( &self, peer_id: FixedBytes<64>, kind: ReputationChangeKind, ); fn reputation_by_id( &self, peer_id: FixedBytes<64>, ) -> impl Future<Output = Result<Option<i32>, NetworkError>> + Send; // Provided methods fn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr) { ... } fn add_peer_with_udp( &self, peer: FixedBytes<64>, tcp_addr: SocketAddr, udp_addr: SocketAddr, ) { ... } fn add_trusted_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr) { ... } fn add_trusted_peer_with_udp( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, 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: FixedBytes<64>)

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: FixedBytes<64>, 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: FixedBytes<64>, ) -> 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<FixedBytes<64>>, ) -> 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: FixedBytes<64>, kind: PeerKind)

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

Source

fn disconnect_peer(&self, peer: FixedBytes<64>)

Disconnect an existing connection to the given peer.

Source

fn disconnect_peer_with_reason( &self, peer: FixedBytes<64>, reason: DisconnectReason, )

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

Source

fn connect_peer_kind( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, kind: ReputationChangeKind)

Send a reputation change for the given peer.

Source

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

Get the reputation of a peer.

Provided Methods§

Source

fn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Adds a peer to the peer set with TCP SocketAddr.

Source

fn add_peer_with_udp( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, tcp_addr: SocketAddr)

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

Source

fn add_trusted_peer_with_udp( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

fn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

fn add_peer_with_udp( &self, peer: FixedBytes<64>, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Source§

fn add_trusted_peer_id(&self, peer: FixedBytes<64>)

Source§

fn add_trusted_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

fn add_trusted_peer_with_udp( &self, peer: FixedBytes<64>, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Source§

fn add_peer_kind( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send

Source§

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

Source§

fn remove_peer(&self, peer: FixedBytes<64>, kind: PeerKind)

Source§

fn disconnect_peer(&self, peer: FixedBytes<64>)

Source§

fn disconnect_peer_with_reason( &self, peer: FixedBytes<64>, reason: DisconnectReason, )

Source§

fn connect_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

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

Source§

fn reputation_change(&self, peer_id: FixedBytes<64>, kind: ReputationChangeKind)

Source§

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

Source§

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

Source§

fn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

fn add_peer_with_udp( &self, peer: FixedBytes<64>, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Source§

fn add_trusted_peer_id(&self, peer: FixedBytes<64>)

Source§

fn add_trusted_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

fn add_trusted_peer_with_udp( &self, peer: FixedBytes<64>, tcp_addr: SocketAddr, udp_addr: SocketAddr, )

Source§

fn add_peer_kind( &self, peer: FixedBytes<64>, 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: FixedBytes<64>, ) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send

Source§

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

Source§

fn remove_peer(&self, peer: FixedBytes<64>, kind: PeerKind)

Source§

fn disconnect_peer(&self, peer: FixedBytes<64>)

Source§

fn disconnect_peer_with_reason( &self, peer: FixedBytes<64>, reason: DisconnectReason, )

Source§

fn connect_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)

Source§

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

Source§

fn reputation_change(&self, peer_id: FixedBytes<64>, kind: ReputationChangeKind)

Source§

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

Implementors§