Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ where
NetworkHandleMessage::AddPeerAddress(peer, addr) => {
self.swarm.state_mut().add_peer_address(peer, addr);
}
NetworkHandleMessage::DisconnectPeer(peer_id) => {
self.swarm.sessions_mut().disconnect(peer_id, None);
NetworkHandleMessage::DisconnectPeer(peer_id, reason) => {
self.swarm.sessions_mut().disconnect(peer_id, reason);
}
NetworkHandleMessage::ReputationChange(peer_id, kind) => {
self.swarm.state_mut().peers_mut().apply_reputation_change(&peer_id, kind);
Expand Down
12 changes: 9 additions & 3 deletions crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
FetchClient,
};
use parking_lot::Mutex;
use reth_eth_wire::{NewBlock, NewPooledTransactionHashes, SharedTransactions};
use reth_eth_wire::{DisconnectReason, NewBlock, NewPooledTransactionHashes, SharedTransactions};
use reth_interfaces::p2p::headers::client::StatusUpdater;
use reth_primitives::{PeerId, TransactionSigned, TxHash, H256, U256};
use std::{
Expand Down Expand Up @@ -124,7 +124,13 @@ impl NetworkHandle {
/// Sends a message to the [`NetworkManager`](crate::NetworkManager) to disconnect an existing
/// connection to the given peer.
pub fn disconnect_peer(&self, peer: PeerId) {
self.send_message(NetworkHandleMessage::DisconnectPeer(peer))
self.send_message(NetworkHandleMessage::DisconnectPeer(peer, None))
}

/// Sends a message to the [`NetworkManager`](crate::NetworkManager) to disconnect an existing
/// connection to the given peer using the provided reason
pub fn disconnect_peer_with_reason(&self, peer: PeerId, reason: DisconnectReason) {
self.send_message(NetworkHandleMessage::DisconnectPeer(peer, Some(reason)))
}

/// Send a reputation change for the given peer.
Expand Down Expand Up @@ -183,7 +189,7 @@ pub(crate) enum NetworkHandleMessage {
/// Adds an address for a peer.
AddPeerAddress(PeerId, SocketAddr),
/// Disconnect a connection to a peer if it exists.
DisconnectPeer(PeerId),
DisconnectPeer(PeerId, Option<DisconnectReason>),
/// Add a new listener for [`NetworkEvent`].
EventListener(UnboundedSender<NetworkEvent>),
/// Broadcast event to announce a new block to all nodes.
Expand Down