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§
Sourcefn add_trusted_peer_id(&self, peer: FixedBytes<64>)
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.
Sourcefn add_peer_kind(
&self,
peer: FixedBytes<64>,
kind: PeerKind,
tcp_addr: SocketAddr,
udp_addr: Option<SocketAddr>,
)
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.
Sourcefn get_peers_by_kind(
&self,
kind: PeerKind,
) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
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.
Sourcefn get_all_peers(
&self,
) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
fn get_all_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
Returns the rpc PeerInfo
for all connected peers.
Sourcefn get_peer_by_id(
&self,
peer_id: FixedBytes<64>,
) -> impl Future<Output = Result<Option<PeerInfo>, NetworkError>> + Send
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.
Sourcefn get_peers_by_id(
&self,
peer_ids: Vec<FixedBytes<64>>,
) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
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.
Sourcefn remove_peer(&self, peer: FixedBytes<64>, kind: PeerKind)
fn remove_peer(&self, peer: FixedBytes<64>, kind: PeerKind)
Removes a peer from the peer set that corresponds to given kind.
Sourcefn disconnect_peer(&self, peer: FixedBytes<64>)
fn disconnect_peer(&self, peer: FixedBytes<64>)
Disconnect an existing connection to the given peer.
Sourcefn disconnect_peer_with_reason(
&self,
peer: FixedBytes<64>,
reason: DisconnectReason,
)
fn disconnect_peer_with_reason( &self, peer: FixedBytes<64>, reason: DisconnectReason, )
Disconnect an existing connection to the given peer using the provided reason
Sourcefn connect_peer_kind(
&self,
peer: FixedBytes<64>,
kind: PeerKind,
tcp_addr: SocketAddr,
udp_addr: Option<SocketAddr>,
)
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.
Sourcefn reputation_change(&self, peer_id: FixedBytes<64>, kind: ReputationChangeKind)
fn reputation_change(&self, peer_id: FixedBytes<64>, kind: ReputationChangeKind)
Send a reputation change for the given peer.
Sourcefn reputation_by_id(
&self,
peer_id: FixedBytes<64>,
) -> impl Future<Output = Result<Option<i32>, NetworkError>> + Send
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§
Sourcefn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)
fn add_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)
Adds a peer to the peer set with TCP SocketAddr
.
Sourcefn add_peer_with_udp(
&self,
peer: FixedBytes<64>,
tcp_addr: SocketAddr,
udp_addr: SocketAddr,
)
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
.
Sourcefn add_trusted_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)
fn add_trusted_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)
Adds a trusted peer to the peer set with TCP SocketAddr
.
Sourcefn add_trusted_peer_with_udp(
&self,
peer: FixedBytes<64>,
tcp_addr: SocketAddr,
udp_addr: SocketAddr,
)
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.
Sourcefn get_trusted_peers(
&self,
) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
fn get_trusted_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
Returns the rpc PeerInfo
for all connected [PeerKind::Trusted
] peers.
Sourcefn get_basic_peers(
&self,
) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
fn get_basic_peers( &self, ) -> impl Future<Output = Result<Vec<PeerInfo>, NetworkError>> + Send
Returns the rpc PeerInfo
for all connected [PeerKind::Basic
] peers.
Sourcefn connect_peer(&self, peer: FixedBytes<64>, tcp_addr: SocketAddr)
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.