From 3196140ae48d61a1581eb724f71d0006a147bcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Cig=C3=A1nek?= Date: Thu, 11 Mar 2021 09:43:07 +0100 Subject: [PATCH] refactor: remove &mut from Endpoint::disconnect_from --- src/connection_pool.rs | 2 +- src/endpoint.rs | 2 +- src/tests/common.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/connection_pool.rs b/src/connection_pool.rs index dba8502b..5b0e1444 100644 --- a/src/connection_pool.rs +++ b/src/connection_pool.rs @@ -53,7 +53,7 @@ impl ConnectionPool { .is_some() } - pub fn remove(&mut self, addr: &SocketAddr) -> Vec { + pub fn remove(&self, addr: &SocketAddr) -> Vec { let mut store = self.store.lock().unwrap_or_else(PoisonError::into_inner); let keys_to_remove = store diff --git a/src/endpoint.rs b/src/endpoint.rs index 90c7d3fb..28f1f72a 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -271,7 +271,7 @@ impl Endpoint { } /// Removes all existing connections to a given peer - pub fn disconnect_from(&mut self, peer_addr: &SocketAddr) -> Result<()> { + pub fn disconnect_from(&self, peer_addr: &SocketAddr) -> Result<()> { self.connection_pool .remove(peer_addr) .iter() diff --git a/src/tests/common.rs b/src/tests/common.rs index c330cb44..b041244a 100644 --- a/src/tests/common.rs +++ b/src/tests/common.rs @@ -173,7 +173,7 @@ async fn disconnection() -> Result<()> { utils::init_logging(); let qp2p = new_qp2p()?; - let (mut alice, mut alice_incoming_connections, _, mut alice_disconnections) = + let (alice, mut alice_incoming_connections, _, mut alice_disconnections) = qp2p.new_endpoint().await?; let alice_addr = alice.socket_addr(); @@ -234,7 +234,7 @@ async fn simultaneous_incoming_and_outgoing_connections() -> Result<()> { ) = qp2p.new_endpoint().await?; let alice_addr = alice.socket_addr(); - let (mut bob, mut bob_incoming_connections, mut bob_incoming_messages, _) = + let (bob, mut bob_incoming_connections, mut bob_incoming_messages, _) = qp2p.new_endpoint().await?; let bob_addr = bob.socket_addr();