From d2844e43f06d2b72d2816fec7fca6003e1b1c458 Mon Sep 17 00:00:00 2001 From: dasman Date: Sun, 4 Feb 2024 04:29:42 +0300 Subject: [PATCH] src/net: cargo fmt and clippy needless_borrow fix --- src/net/hosts/refinery.rs | 8 ++++---- src/net/protocol/protocol_address.rs | 7 ++++--- src/net/protocol/protocol_seed.rs | 2 +- src/net/session/inbound_session.rs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/net/hosts/refinery.rs b/src/net/hosts/refinery.rs index f71fb4c57..36b56dcea 100644 --- a/src/net/hosts/refinery.rs +++ b/src/net/hosts/refinery.rs @@ -109,12 +109,12 @@ impl GreylistRefinery { } // Don't refine nodes that we are already connected to. - if self.p2p().exists(&url).await { + if self.p2p().exists(url).await { continue } // Don't refine nodes that we are trying to connect to. - if !self.p2p().add_pending(&url).await { + if !self.p2p().add_pending(url).await { continue } @@ -123,7 +123,7 @@ impl GreylistRefinery { greylist.remove(position); // Remove connection from pending - self.p2p().remove_pending(&url).await; + self.p2p().remove_pending(url).await; debug!( target: "net::refinery", "Peer {} is non-responsive. Removed from greylist", url, @@ -142,7 +142,7 @@ impl GreylistRefinery { hosts.greylist_remove(url, position).await; // Remove connection from pending - self.p2p().remove_pending(&url).await; + self.p2p().remove_pending(url).await; } None => { debug!(target: "net::refinery", "No matching greylist entries found. Cannot proceed with refinery"); diff --git a/src/net/protocol/protocol_address.rs b/src/net/protocol/protocol_address.rs index 4b83e4e06..9f32c3869 100644 --- a/src/net/protocol/protocol_address.rs +++ b/src/net/protocol/protocol_address.rs @@ -48,7 +48,7 @@ use crate::Result; /// prioritize them first. /// /// 2. Then select nodes matching the requested transports from the -/// whitelist. +/// whitelist. /// /// 3. Next select whitelist nodes that don't match our transports. We do /// this so that nodes share and propagate nodes of different transports, @@ -167,7 +167,8 @@ impl ProtocolAddress { debug!(target: "net::protocol_address::handle_receive_get_addrs()", "Fetching whitelist entries with schemes"); addrs.append( - &mut self.hosts + &mut self + .hosts .whitelist_fetch_n_random_with_schemes( &get_addrs_msg.transports, get_addrs_msg.max, @@ -234,7 +235,7 @@ impl ProtocolAddress { let mut addrs = vec![]; let inbound = self.p2p.session_inbound(); for (addr, last_seen) in inbound.ping_self.addrs.lock().await.iter() { - addrs.push((addr.clone(), last_seen.clone())); + addrs.push((addr.clone(), *last_seen)); } debug!(target: "net::protocol_address::send_my_addrs()", diff --git a/src/net/protocol/protocol_seed.rs b/src/net/protocol/protocol_seed.rs index 120225139..a1a9ef9fb 100644 --- a/src/net/protocol/protocol_seed.rs +++ b/src/net/protocol/protocol_seed.rs @@ -80,7 +80,7 @@ impl ProtocolSeed { let mut addrs = vec![]; let inbound = self.p2p.session_inbound(); for (addr, last_seen) in inbound.ping_self.addrs.lock().await.iter() { - addrs.push((addr.clone(), last_seen.clone())); + addrs.push((addr.clone(), *last_seen)); } debug!(target: "net::protocol_seed::send_my_addrs()", diff --git a/src/net/session/inbound_session.rs b/src/net/session/inbound_session.rs index a26d265d4..843c91ad3 100644 --- a/src/net/session/inbound_session.rs +++ b/src/net/session/inbound_session.rs @@ -308,7 +308,7 @@ impl PingSelfProcess { let mut addrs = self.addrs.lock().await; if addrs.contains_key(addr) { - let val = addrs.get_mut(&addr).unwrap(); + let val = addrs.get_mut(addr).unwrap(); *val = last_seen; } addrs.insert(addr.clone(), last_seen);