mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat : add the ability to connect to a peer (#10028)
Co-authored-by: Emilia Hane <emiliaha95@gmail.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -184,6 +184,21 @@ pub trait Peers: PeersInfo {
|
||||
/// Disconnect an existing connection to the given peer using the provided reason
|
||||
fn disconnect_peer_with_reason(&self, peer: PeerId, reason: DisconnectReason);
|
||||
|
||||
/// 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`.
|
||||
fn connect_peer(&self, peer: PeerId, tcp_addr: SocketAddr) {
|
||||
self.connect_peer_kind(peer, PeerKind::Static, tcp_addr, None)
|
||||
}
|
||||
|
||||
/// Connects a peer to the known peer set, with the given kind.
|
||||
fn connect_peer_kind(
|
||||
&self,
|
||||
peer: PeerId,
|
||||
kind: PeerKind,
|
||||
tcp_addr: SocketAddr,
|
||||
udp_addr: Option<SocketAddr>,
|
||||
);
|
||||
|
||||
/// Send a reputation change for the given peer.
|
||||
fn reputation_change(&self, peer_id: PeerId, kind: ReputationChangeKind);
|
||||
|
||||
|
||||
@ -102,6 +102,15 @@ impl Peers for NoopNetwork {
|
||||
|
||||
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) {}
|
||||
|
||||
async fn reputation_by_id(&self, _peer_id: PeerId) -> Result<Option<Reputation>, NetworkError> {
|
||||
|
||||
Reference in New Issue
Block a user