Jelajahi Sumber

net: chore clippy

skoupidi 1 tahun lalu
induk
melakukan
ea6139cead

+ 7 - 7
src/net/acceptor.rs

@@ -75,7 +75,7 @@ impl Acceptor {
         #[cfg(feature = "p2p-tor")]
         if endpoint.scheme() == "tor" {
             let onion_addr = listener.endpoint().await;
-            info!("[P2P] Adding {} to external_addrs", onion_addr);
+            info!("[P2P] Adding {onion_addr} to external_addrs");
             self.session
                 .upgrade()
                 .unwrap()
@@ -147,7 +147,7 @@ impl Acceptor {
                     if hosts.container.contains(HostColor::Black as usize, &url) ||
                         hosts.block_all_ports(&url)
                     {
-                        warn!(target: "net::acceptor::run_accept_loop()", "Peer {} is blacklisted", url);
+                        warn!(target: "net::acceptor::run_accept_loop()", "Peer {url} is blacklisted");
                         continue
                     }
 
@@ -204,14 +204,14 @@ impl Acceptor {
                     x => {
                         warn!(
                             target: "net::acceptor::run_accept_loop()",
-                            "[P2P] Unhandled OS Error: {} {}", e, x,
+                            "[P2P] Unhandled OS Error: {e} {x}"
                         );
                         continue
 
                         /*
                         error!(
                             target: "net::acceptor::run_accept_loop()",
-                            "[P2P] Acceptor failed listening: {} ({})", e, x,
+                            "[P2P] Acceptor failed listening: {e} ({x})"
                         );
                         error!(
                             target: "net::acceptor::run_accept_loop()",
@@ -231,7 +231,7 @@ impl Acceptor {
                         if let Some(inner) = inner.downcast_ref::<futures_rustls::rustls::Error>() {
                             error!(
                                 target: "net::acceptor::run_accept_loop()",
-                                "[P2P] rustls listener error: {:?}", inner,
+                                "[P2P] rustls listener error: {inner:?}"
                             );
                             continue
                         }
@@ -239,7 +239,7 @@ impl Acceptor {
 
                     error!(
                         target: "net::acceptor::run_accept_loop()",
-                        "[P2P] Unhandled ErrorKind::Other error: {:?}", e,
+                        "[P2P] Unhandled ErrorKind::Other error: {e:?}"
                     );
                     return Err(e.into())
                 }
@@ -248,7 +248,7 @@ impl Acceptor {
                 Err(e) => {
                     error!(
                         target: "net::acceptor::run_accept_loop()",
-                        "[P2P] Unhandled listener.next() error: {}", e,
+                        "[P2P] Unhandled listener.next() error: {e}"
                     );
                     /*
                     error!(

+ 32 - 35
src/net/channel.rs

@@ -151,7 +151,7 @@ impl Channel {
     /// Starts the channel. Runs a receive loop to start receiving messages
     /// or handles a network failure.
     pub fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) {
-        debug!(target: "net::channel::start()", "START {:?}", self);
+        debug!(target: "net::channel::start()", "START {self:?}");
 
         let self_ = self.clone();
         self.receive_task.clone().start(
@@ -161,21 +161,21 @@ impl Channel {
             executor,
         );
 
-        debug!(target: "net::channel::start()", "END {:?}", self);
+        debug!(target: "net::channel::start()", "END {self:?}");
     }
 
     /// Stops the channel.
     /// Notifies all publishers that the channel has been closed in `handle_stop()`.
     pub async fn stop(&self) {
-        debug!(target: "net::channel::stop()", "START {:?}", self);
+        debug!(target: "net::channel::stop()", "START {self:?}");
         self.receive_task.stop().await;
-        debug!(target: "net::channel::stop()", "END {:?}", self);
+        debug!(target: "net::channel::stop()", "END {self:?}");
     }
 
     /// Creates a subscription to a stopped signal.
     /// If the channel is stopped then this will return a ChannelStopped error.
     pub async fn subscribe_stop(&self) -> Result<Subscription<Error>> {
-        debug!(target: "net::channel::subscribe_stop()", "START {:?}", self);
+        debug!(target: "net::channel::subscribe_stop()", "START {self:?}");
 
         if self.is_stopped() {
             return Err(Error::ChannelStopped)
@@ -183,7 +183,7 @@ impl Channel {
 
         let sub = self.stop_publisher.clone().subscribe().await;
 
-        debug!(target: "net::channel::subscribe_stop()", "END {:?}", self);
+        debug!(target: "net::channel::subscribe_stop()", "END {self:?}");
 
         Ok(sub)
     }
@@ -219,8 +219,8 @@ impl Channel {
         metering_config: &MeteringConfiguration,
     ) -> Result<()> {
         debug!(
-             target: "net::channel::send()", "[START] command={} {:?}",
-             message.command, self,
+             target: "net::channel::send()", "[START] command={} {self:?}",
+             message.command,
         );
 
         // Check if we need to initialize a `MeteringQueue`
@@ -243,8 +243,7 @@ impl Channel {
             let sleep_time = 2 * sleep_time;
             debug!(
                 target: "net::channel::send()",
-                "[P2P] Channel rate limit is active, sleeping before sending for: {} (ms)",
-                sleep_time,
+                "[P2P] Channel rate limit is active, sleeping before sending for: {sleep_time} (ms)"
             );
             msleep(sleep_time).await;
         }
@@ -258,8 +257,7 @@ impl Channel {
         if let Err(e) = self.send_message(message).await {
             if self.session.upgrade().unwrap().type_id() & (SESSION_ALL & !SESSION_REFINE) != 0 {
                 error!(
-                    target: "net::channel::send()", "[P2P] Channel send error for [{:?}]: {}",
-                    self, e
+                    target: "net::channel::send()", "[P2P] Channel send error for [{self:?}]: {e}"
                 );
             }
             self.stop().await;
@@ -267,8 +265,8 @@ impl Channel {
         }
 
         debug!(
-            target: "net::channel::send()", "[END] command={} {:?}",
-            message.command, self
+            target: "net::channel::send()", "[END] command={} {self:?}",
+            message.command
         );
 
         Ok(())
@@ -304,8 +302,8 @@ impl Channel {
         stream.write_all(&message.payload).await?;
         written += message.payload.len();
 
-        trace!(target: "net::channel::send_message()", "Sent payload {} bytes, total bytes {}",
-            message.payload.len(), written);
+        trace!(target: "net::channel::send_message()", "Sent payload {} bytes, total bytes {written}",
+            message.payload.len());
 
         stream.flush().await?;
 
@@ -327,7 +325,7 @@ impl Channel {
         trace!(target: "net::channel::read_command()", "Reading magic...");
         stream.read_exact(&mut magic).await?;
 
-        trace!(target: "net::channel::read_command()", "Read magic {:?}", magic);
+        trace!(target: "net::channel::read_command()", "Read magic {magic:?}");
         let magic_bytes = self.p2p().settings().read().await.magic_bytes.0;
         if magic != magic_bytes {
             error!(target: "net::channel::read_command", "Error: Magic bytes mismatch");
@@ -352,15 +350,15 @@ impl Channel {
     /// Subscribe to a message on the message subsystem.
     pub async fn subscribe_msg<M: message::Message>(&self) -> Result<MessageSubscription<M>> {
         debug!(
-            target: "net::channel::subscribe_msg()", "[START] command={} {:?}",
-            M::NAME, self
+            target: "net::channel::subscribe_msg()", "[START] command={} {self:?}",
+            M::NAME
         );
 
         let sub = self.message_subsystem.subscribe::<M>().await;
 
         debug!(
-            target: "net::channel::subscribe_msg()", "[END] command={} {:?}",
-            M::NAME, self
+            target: "net::channel::subscribe_msg()", "[END] command={} {self:?}",
+            M::NAME
         );
 
         sub
@@ -369,7 +367,7 @@ impl Channel {
     /// Handle network errors. Panic if error passes silently, otherwise
     /// broadcast the error.
     async fn handle_stop(self: Arc<Self>, result: Result<()>) {
-        debug!(target: "net::channel::handle_stop()", "[START] {:?}", self);
+        debug!(target: "net::channel::handle_stop()", "[START] {self:?}");
 
         self.stopped.store(true, SeqCst);
 
@@ -382,12 +380,12 @@ impl Channel {
             }
         }
 
-        debug!(target: "net::channel::handle_stop()", "[END] {:?}", self);
+        debug!(target: "net::channel::handle_stop()", "[END] {self:?}");
     }
 
     /// Run the receive loop. Start receiving messages or handle network failure.
     async fn main_receive_loop(self: Arc<Self>) -> Result<()> {
-        debug!(target: "net::channel::main_receive_loop()", "[START] {:?}", self);
+        debug!(target: "net::channel::main_receive_loop()", "[START] {self:?}");
 
         // Acquire reader lock
         let reader = &mut *self.reader.lock().await;
@@ -401,7 +399,7 @@ impl Channel {
                         info!(
                             target: "net::channel::main_receive_loop()",
                             "[P2P] Channel {} disconnected",
-                            self.address(),
+                            self.address()
                         );
                     } else if self.session.upgrade().unwrap().type_id() &
                         (SESSION_ALL & !SESSION_REFINE) !=
@@ -409,14 +407,14 @@ impl Channel {
                     {
                         error!(
                             target: "net::channel::main_receive_loop()",
-                            "[P2P] Read error on channel {}: {}",
-                            self.address(), err,
+                            "[P2P] Read error on channel {}: {err}",
+                            self.address()
                         );
                     }
 
                     debug!(
                         target: "net::channel::main_receive_loop()",
-                        "Stopping channel {:?}", self
+                        "Stopping channel {self:?}"
                     );
                     return Err(Error::ChannelStopped)
                 }
@@ -453,8 +451,7 @@ impl Channel {
                     if self.session.upgrade().unwrap().type_id() != SESSION_REFINE {
                         warn!(
                         target: "net::channel::main_receive_loop()",
-                        "MissingDispatcher|MessageInvalid|MeteringLimitExcheeded for command={}, channel={:?}",
-                        command, self
+                        "MissingDispatcher|MessageInvalid|MeteringLimitExcheeded for command={command}, channel={self:?}"
                         );
 
                         if let BanPolicy::Strict = self.p2p().settings().read().await.ban_policy {
@@ -471,7 +468,7 @@ impl Channel {
 
     /// Ban a malicious peer and stop the channel.
     pub async fn ban(&self) {
-        debug!(target: "net::channel::ban()", "START {:?}", self);
+        debug!(target: "net::channel::ban()", "START {self:?}");
         debug!(target: "net::channel::ban()", "Peer: {:?}", self.address());
 
         // Just store the hostname if this is an inbound session.
@@ -505,17 +502,17 @@ impl Channel {
         };
 
         let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
-        info!(target: "net::channel::ban()", "Blacklisting peer={}", peer);
+        info!(target: "net::channel::ban()", "Blacklisting peer={peer}");
         match self.p2p().hosts().move_host(&peer, last_seen, HostColor::Black) {
             Ok(()) => {
-                info!(target: "net::channel::ban()", "Peer={} blacklisted successfully", peer);
+                info!(target: "net::channel::ban()", "Peer={peer} blacklisted successfully");
             }
             Err(e) => {
-                warn!(target: "net::channel::ban()", "Could not blacklisted peer={}, err={}", peer, e);
+                warn!(target: "net::channel::ban()", "Could not blacklisted peer={peer}, err={e}");
             }
         }
         self.stop().await;
-        debug!(target: "net::channel::ban()", "STOP {:?}", self);
+        debug!(target: "net::channel::ban()", "STOP {self:?}");
     }
 
     /// Returns the relevant socket address for this connection.  If this is

+ 1 - 1
src/net/connector.rs

@@ -58,7 +58,7 @@ impl Connector {
     pub async fn connect(&self, url: &Url) -> Result<(Url, ChannelPtr)> {
         let hosts = self.session.upgrade().unwrap().p2p().hosts();
         if hosts.container.contains(HostColor::Black as usize, url) || hosts.block_all_ports(url) {
-            warn!(target: "net::connector::connect", "Peer {} is blacklisted", url);
+            warn!(target: "net::connector::connect", "Peer {url} is blacklisted");
             return Err(Error::ConnectFailed)
         }
 

+ 54 - 56
src/net/hosts.rs

@@ -364,8 +364,8 @@ impl HostContainer {
 
         let mut list = self.hostlists[color].write().unwrap();
         list.push((addr.clone(), last_seen));
-        debug!(target: "net::hosts::store()", "Added [{}] to {:?} list",
-               addr, HostColor::try_from(color).unwrap());
+        debug!(target: "net::hosts::store()", "Added [{addr}] to {:?} list",
+               HostColor::try_from(color).unwrap());
 
         trace!(target: "net::hosts::store()", "[END] list={:?}",
                HostColor::try_from(color).unwrap());
@@ -379,11 +379,11 @@ impl HostContainer {
         let mut list = self.hostlists[color_code].write().unwrap();
         if let Some(entry) = list.iter_mut().find(|(u, _)| *u == addr) {
             entry.1 = last_seen;
-            debug!(target: "net::hosts::store_or_update()", "Updated [{}] entry on {:?} list",
-                addr, color.clone());
+            debug!(target: "net::hosts::store_or_update()", "Updated [{addr}] entry on {:?} list",
+                color.clone());
         } else {
             list.push((addr.clone(), last_seen));
-            debug!(target: "net::hosts::store_or_update()", "Added [{}] to {:?} list", addr, color);
+            debug!(target: "net::hosts::store_or_update()", "Added [{addr}] to {color:?} list");
         }
         trace!(target: "net::hosts::store_or_update()", "[STOP]");
     }
@@ -422,7 +422,7 @@ impl HostContainer {
         transport_mixing: bool,
         tor_socks5_proxy: Url,
     ) -> Vec<(Url, u64)> {
-        trace!(target: "net::hosts::fetch_addrs()", "[START] {:?}", color);
+        trace!(target: "net::hosts::fetch_addrs()", "[START] {color:?}");
         let mut hosts = vec![];
         let index = color as usize;
 
@@ -574,7 +574,7 @@ impl HostContainer {
         schemes: &[String],
     ) -> Option<((Url, u64), usize)> {
         // Retrieve all peers corresponding to that transport schemes
-        trace!(target: "net::hosts::fetch_random_with_schemes()", "[START] {:?}", color);
+        trace!(target: "net::hosts::fetch_random_with_schemes()", "[START] {color:?}");
         let list = self.fetch_with_schemes(color as usize, schemes, None);
 
         if list.is_empty() {
@@ -588,7 +588,7 @@ impl HostContainer {
 
     /// Get up to n random peers. Schemes are not taken into account.
     pub(in crate::net) fn fetch_n_random(&self, color: HostColor, n: u32) -> Vec<(Url, u64)> {
-        trace!(target: "net::hosts::fetch_n_random()", "[START] {:?}", color);
+        trace!(target: "net::hosts::fetch_n_random()", "[START] {color:?}");
         let n = n as usize;
         if n == 0 {
             return vec![]
@@ -618,7 +618,7 @@ impl HostContainer {
         schemes: &[String],
         n: u32,
     ) -> Vec<(Url, u64)> {
-        trace!(target: "net::hosts::fetch_n_random_with_schemes()", "[START] {:?}", color);
+        trace!(target: "net::hosts::fetch_n_random_with_schemes()", "[START] {color:?}");
         let index = color as usize;
         let n = n as usize;
         if n == 0 {
@@ -646,7 +646,7 @@ impl HostContainer {
         schemes: &[String],
         n: u32,
     ) -> Vec<(Url, u64)> {
-        trace!(target: "net::hosts::fetch_excluding_schemes()", "[START] {:?}", color);
+        trace!(target: "net::hosts::fetch_excluding_schemes()", "[START] {color:?}");
         let index = color as usize;
         let n = n as usize;
         if n == 0 {
@@ -671,7 +671,7 @@ impl HostContainer {
         let color_code = color.clone() as usize;
         let mut list = self.hostlists[color_code].write().unwrap();
         if let Some(position) = list.iter().position(|(u, _)| u == addr) {
-            debug!(target: "net::hosts::remove_if_exists()", "Removing addr={} list={:?}", addr, color);
+            debug!(target: "net::hosts::remove_if_exists()", "Removing addr={addr} list={color:?}");
             list.remove(position);
         }
     }
@@ -732,7 +732,7 @@ impl HostContainer {
 
                     debug!(
                         target: "net::hosts::resize()",
-                        "{:?}list reached max size. Removed {:?}", color, last_entry,
+                        "{color:?}list reached max size. Removed {last_entry:?}"
                     );
                 }
             }
@@ -756,7 +756,7 @@ impl HostContainer {
             // misreporting the last_seen field.
             if now < last_seen {
                 debug!(target: "net::hosts::refresh()",
-                "last_seen [{}] is newer than current system time [{}]. Skipping", now, last_seen);
+                "last_seen [{now}] is newer than current system time [{last_seen}]. Skipping");
                 continue
             }
             if (now - last_seen) > max_age {
@@ -765,7 +765,7 @@ impl HostContainer {
         }
 
         for item in old_items {
-            debug!(target: "net::hosts::refresh()", "Removing {:?}", item);
+            debug!(target: "net::hosts::refresh()", "Removing {item:?}");
             self.remove_if_exists(color.clone(), &item);
         }
     }
@@ -784,7 +784,7 @@ impl HostContainer {
 
         let contents = load_file(&path);
         if let Err(e) = contents {
-            warn!(target: "net::hosts::load_hosts()", "Failed retrieving saved hosts: {}", e);
+            warn!(target: "net::hosts::load_hosts()", "Failed retrieving saved hosts: {e}");
             return Ok(())
         }
 
@@ -794,7 +794,7 @@ impl HostContainer {
             let url = match Url::parse(data[1]) {
                 Ok(u) => u,
                 Err(e) => {
-                    debug!(target: "net::hosts::load_hosts()", "Skipping malformed URL {}", e);
+                    debug!(target: "net::hosts::load_hosts()", "Skipping malformed URL {e}");
                     continue
                 }
             };
@@ -802,7 +802,7 @@ impl HostContainer {
             let last_seen = match data[2].parse::<u64>() {
                 Ok(t) => t,
                 Err(e) => {
-                    debug!(target: "net::hosts::load_hosts()", "Skipping malformed last seen {}", e);
+                    debug!(target: "net::hosts::load_hosts()", "Skipping malformed last seen {e}");
                     continue
                 }
             };
@@ -854,15 +854,14 @@ impl HostContainer {
 
         for (name, list) in hostlist {
             for (url, last_seen) in list {
-                tsv.push_str(&format!("{}\t{}\t{}\n", name, url, last_seen));
+                tsv.push_str(&format!("{name}\t{url}\t{last_seen}\n"));
             }
         }
 
         if !tsv.is_empty() {
-            info!(target: "net::hosts::save_hosts()", "Saving hosts to: {:?}",
-                  path);
+            info!(target: "net::hosts::save_hosts()", "Saving hosts to: {path:?}");
             if let Err(e) = save_file(&path, &tsv) {
-                error!(target: "net::hosts::save_hosts()", "Failed saving hosts: {}", e);
+                error!(target: "net::hosts::save_hosts()", "Failed saving hosts: {e}");
             }
         }
 
@@ -941,8 +940,8 @@ impl Hosts {
         // Then ensure we aren't currently trying to add this peer to the hostlist.
         for (i, (addr, last_seen)) in filtered_addrs.iter().enumerate() {
             if let Err(e) = self.try_register(addr.clone(), HostState::Insert) {
-                debug!(target: "net::hosts::store_or_update", "Cannot insert addr={}, err={}",
-                       addr.clone(), e);
+                debug!(target: "net::hosts::store_or_update", "Cannot insert addr={}, err={e}",
+                       addr.clone());
 
                 continue
             }
@@ -975,8 +974,8 @@ impl Hosts {
     ) -> Result<HostState> {
         let mut registry = self.registry.lock().unwrap();
 
-        trace!(target: "net::hosts::try_update_registry()", "Try register addr={}, state={}",
-               addr, &new_state);
+        trace!(target: "net::hosts::try_update_registry()", "Try register addr={addr}, state={}",
+               &new_state);
 
         if registry.contains_key(&addr) {
             let current_state = registry.get(&addr).unwrap().clone();
@@ -995,13 +994,13 @@ impl Hosts {
                 registry.insert(addr.clone(), state.clone());
             }
 
-            trace!(target: "net::hosts::try_update_registry()", "Returning result {:?}", result);
+            trace!(target: "net::hosts::try_update_registry()", "Returning result {result:?}");
 
             result
         } else {
             // We don't know this peer. We can safely update the state.
-            debug!(target: "net::hosts::try_update_registry()", "Inserting addr={}, state={}",
-                   addr, &new_state);
+            debug!(target: "net::hosts::try_update_registry()", "Inserting addr={addr}, state={}",
+                   &new_state);
 
             registry.insert(addr.clone(), new_state.clone());
 
@@ -1040,12 +1039,12 @@ impl Hosts {
             if let Err(e) = self.try_register(host.clone(), HostState::Connect) {
                 trace!(
                     target: "net::hosts::check_addrs",
-                    "Skipping addr={}, err={}", host.clone(), e,
+                    "Skipping addr={}, err={e}", host.clone(),
                 );
                 continue
             }
 
-            debug!(target: "net::hosts::check_addrs()", "Found valid host {}", host);
+            debug!(target: "net::hosts::check_addrs()", "Found valid host {host}");
             return Some((host.clone(), last_seen))
         }
 
@@ -1220,9 +1219,9 @@ impl Hosts {
             for scheme in schemes {
                 for &port in &ports {
                     let url_string = if port == 0 {
-                        format!("{}://{}", scheme, hostname)
+                        format!("{scheme}://{hostname}")
                     } else {
-                        format!("{}://{}:{}", scheme, hostname, port)
+                        format!("{scheme}://{hostname}:{port}")
                     };
 
                     if let Ok(url) = Url::parse(&url_string) {
@@ -1250,7 +1249,7 @@ impl Hosts {
     /// Filter given addresses based on certain rulesets and validity. Strictly called only on
     /// the first time learning of new peers.
     async fn filter_addresses(&self, addrs: &[(Url, u64)]) -> Vec<(Url, u64)> {
-        debug!(target: "net::hosts::filter_addresses", "Filtering addrs: {:?}", addrs);
+        debug!(target: "net::hosts::filter_addresses", "Filtering addrs: {addrs:?}");
         let mut ret = vec![];
 
         // Acquire read lock on P2P settings. Dropped when this function finishes.
@@ -1261,7 +1260,7 @@ impl Hosts {
             if addr_.host_str().is_none() || addr_.port().is_none() || addr_.cannot_be_a_base() {
                 debug!(
                     target: "net::hosts::filter_addresses",
-                    "[{}] has invalid addr format. Skipping", addr_,
+                    "[{addr_}] has invalid addr format. Skipping"
                 );
                 continue
             }
@@ -1270,7 +1269,7 @@ impl Hosts {
             if settings.seeds.contains(addr_) {
                 debug!(
                     target: "net::hosts::filter_addresses",
-                    "[{}] is a configured seed. Skipping", addr_,
+                    "[{addr_}] is a configured seed. Skipping"
                 );
                 continue
             }
@@ -1279,7 +1278,7 @@ impl Hosts {
             if settings.peers.contains(addr_) {
                 debug!(
                     target: "net::hosts::filter_addresses",
-                    "[{}] is a configured peer. Skipping", addr_,
+                    "[{addr_}] is a configured peer. Skipping"
                 );
                 continue
             }
@@ -1290,7 +1289,7 @@ impl Hosts {
             {
                 debug!(
                     target: "net::hosts::filter_addresses",
-                    "[{}] is blacklisted", addr_,
+                    "[{addr_}] is blacklisted"
                 );
                 continue
             }
@@ -1304,7 +1303,7 @@ impl Hosts {
                     if host == ext.host().unwrap() {
                         debug!(
                             target: "net::hosts::filter_addresses",
-                            "[{}] is our own external addr. Skipping", addr_,
+                            "[{addr_}] is our own external addr. Skipping"
                         );
                         continue 'addr_loop
                     }
@@ -1315,7 +1314,7 @@ impl Hosts {
                     if addr_.port() == ext.port() {
                         debug!(
                             target: "net::hosts::filter_addresses",
-                            "[{}] is our own localnet port. Skipping", addr_,
+                            "[{addr_}] is our own localnet port. Skipping"
                         );
                         continue 'addr_loop
                     }
@@ -1328,7 +1327,7 @@ impl Hosts {
             if !settings.localnet && self.is_local_host(addr_) {
                 debug!(
                     target: "net::hosts::filter_addresses",
-                    "[{}] Filtering non-global ranges", addr_,
+                    "[{addr_}] Filtering non-global ranges"
                 );
                 continue
             }
@@ -1343,7 +1342,7 @@ impl Hosts {
                     }
                     trace!(
                         target: "net::hosts::filter_addresses",
-                        "[Tor] Valid: {}", host_str,
+                        "[Tor] Valid: {host_str}"
                     );
                 }
 
@@ -1353,7 +1352,7 @@ impl Hosts {
                 "tcp" | "tcp+tls" => {
                     trace!(
                         target: "net::hosts::filter_addresses",
-                        "[TCP] Valid: {}", host_str,
+                        "[TCP] Valid: {host_str}"
                     );
                 }
 
@@ -1364,7 +1363,7 @@ impl Hosts {
                     }
                     trace!(
                         target: "net::hosts::filter_addresses",
-                        "[I2p] Valid: {}", host_str,
+                        "[I2p] Valid: {host_str}"
                     );
                 }
 
@@ -1404,7 +1403,7 @@ impl Hosts {
                 self.container.contains(HostColor::White as usize, addr_) ||
                 self.container.contains(HostColor::Grey as usize, addr_)
             {
-                debug!(target: "net::hosts::filter_addresses", "[{}] exists! Skipping", addr_);
+                debug!(target: "net::hosts::filter_addresses", "[{addr_}] exists! Skipping");
                 continue
             }
 
@@ -1430,7 +1429,7 @@ impl Hosts {
 
     /// Downgrade host to Greylist, remove from Gold or White list.
     pub fn greylist_host(&self, addr: &Url, last_seen: u64) -> Result<()> {
-        debug!(target: "net::hosts:greylist_host()", "Downgrading addr={}", addr);
+        debug!(target: "net::hosts:greylist_host()", "Downgrading addr={addr}");
         self.move_host(addr, last_seen, HostColor::Grey)?;
 
         // Free up this addr for future operations.
@@ -1440,7 +1439,7 @@ impl Hosts {
     }
 
     pub fn whitelist_host(&self, addr: &Url, last_seen: u64) -> Result<()> {
-        debug!(target: "net::hosts:whitelist_host()", "Upgrading addr={}", addr);
+        debug!(target: "net::hosts:whitelist_host()", "Upgrading addr={addr}");
         self.move_host(addr, last_seen, HostColor::White)?;
 
         // Free up this addr for future operations.
@@ -1468,14 +1467,13 @@ impl Hosts {
         last_seen: u64,
         destination: HostColor,
     ) -> Result<()> {
-        debug!(target: "net::hosts::move_host()", "Trying to move addr={} destination={:?}",
-               addr, destination);
+        debug!(target: "net::hosts::move_host()", "Trying to move addr={addr} destination={destination:?}");
 
         // If we cannot register this address as move, this will simply return here.
         self.try_register(addr.clone(), HostState::Move)?;
 
-        debug!(target: "net::hosts::move_host()", "Moving addr={} destination={:?}",
-            addr.clone(), destination);
+        debug!(target: "net::hosts::move_host()", "Moving addr={} destination={destination:?}",
+            addr.clone());
 
         match destination {
             // Downgrade to grey. Remove from white and gold.
@@ -1719,7 +1717,7 @@ mod tests {
             Url::parse("tcp://192.168.10.65").unwrap(),
         ];
         for host in local_hosts {
-            eprintln!("{}", host);
+            eprintln!("{host}");
             assert!(hosts.is_local_host(&host));
         }
         let remote_hosts: Vec<Url> = vec![
@@ -1833,14 +1831,14 @@ mod tests {
             // Insert 5 items into the darklist with an old timestamp.
             for i in 0..5 {
                 let last_seen = old_timestamp + i;
-                let url = Url::parse(&format!("tcp://old_darklist{}:123", i)).unwrap();
+                let url = Url::parse(&format!("tcp://old_darklist{i}:123")).unwrap();
                 hosts.container.store(HostColor::Dark as usize, url.clone(), last_seen);
             }
 
             // Insert another 5 items into the darklist with a recent timestamp.
             for i in 0..5 {
                 let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
-                let url = Url::parse(&format!("tcp://new_darklist{}:123", i)).unwrap();
+                let url = Url::parse(&format!("tcp://new_darklist{i}:123")).unwrap();
                 hosts.container.store(HostColor::Dark as usize, url.clone(), last_seen);
             }
 
@@ -1862,7 +1860,7 @@ mod tests {
             // Insert another 5 items into the darklist with a timestamp from the future.
             for i in 0..5 {
                 let last_seen = future_timestamp;
-                let url = Url::parse(&format!("tcp://future_darklist{}:123", i)).unwrap();
+                let url = Url::parse(&format!("tcp://future_darklist{i}:123")).unwrap();
                 hosts.container.store(HostColor::Dark as usize, url.clone(), last_seen);
             }
 
@@ -1884,14 +1882,14 @@ mod tests {
             for i in 0..10 {
                 sleep(1).await;
                 let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
-                let url = Url::parse(&format!("tcp://whitelist{}:123", i)).unwrap();
+                let url = Url::parse(&format!("tcp://whitelist{i}:123")).unwrap();
                 hosts.container.store(HostColor::White as usize, url.clone(), last_seen);
             }
 
             for (url, last_seen) in
                 hosts.container.hostlists[HostColor::White as usize].read().unwrap().iter()
             {
-                println!("{} {}", url, last_seen);
+                println!("{url} {last_seen}");
             }
 
             let entry = hosts.container.fetch_last(HostColor::White).unwrap();

+ 10 - 14
src/net/message_publisher.rs

@@ -103,9 +103,8 @@ impl<M: Message> MessageDispatcher<M> {
 
         let msg_result_type = if message.is_ok() { "Ok" } else { "Err" };
         debug!(
-            target: "net::message_publisher::_trigger_all()", "START msg={}({}), subs={}",
-            msg_result_type,
-            M::NAME, subs.len(),
+            target: "net::message_publisher::_trigger_all()", "START msg={msg_result_type}({}), subs={}",
+            M::NAME, subs.len()
         );
 
         // Insert metering information and grab potential sleep time
@@ -143,8 +142,7 @@ impl<M: Message> MessageDispatcher<M> {
         }
 
         debug!(
-            target: "net::message_publisher::_trigger_all()", "END msg={}({}), subs={}",
-            msg_result_type,
+            target: "net::message_publisher::_trigger_all()", "END msg={msg_result_type}({}), subs={}",
             M::NAME, subs.len(),
         );
     }
@@ -166,7 +164,7 @@ impl<M: Message> MessageSubscription<M> {
     pub async fn receive(&self) -> MessageResult<M> {
         let (message, sleep_time) = match self.recv_queue.recv().await {
             Ok(pair) => pair,
-            Err(e) => panic!("MessageSubscription::receive(): recv_queue failed! {}", e),
+            Err(e) => panic!("MessageSubscription::receive(): recv_queue failed! {e}"),
         };
 
         // Check if we need to sleep
@@ -189,7 +187,7 @@ impl<M: Message> MessageSubscription<M> {
         let (message, sleep_time) = match res {
             Ok(pair) => pair,
             Err(e) => {
-                panic!("MessageSubscription::receive_with_timeout(): recv_queue failed! {}", e)
+                panic!("MessageSubscription::receive_with_timeout(): recv_queue failed! {e}")
             }
         };
 
@@ -209,7 +207,7 @@ impl<M: Message> MessageSubscription<M> {
             match self.recv_queue.try_recv() {
                 Ok(_) => continue,
                 Err(smol::channel::TryRecvError::Empty) => return Ok(()),
-                Err(e) => panic!("MessageSubscription::receive(): recv_queue failed! {}", e),
+                Err(e) => panic!("MessageSubscription::receive(): recv_queue failed! {e}"),
             }
         }
     }
@@ -254,8 +252,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
             Err(err) => {
                 error!(
                     target: "net::message_publisher::trigger()",
-                    "Unable to decode VarInt. Dropping...: {}",
-                    err,
+                    "Unable to decode VarInt. Dropping...: {err}"
                 );
                 return Err(Error::MessageInvalid)
             }
@@ -265,8 +262,8 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
         if M::MAX_BYTES > 0 && length > M::MAX_BYTES {
             error!(
                 target: "net::message_publisher::trigger()",
-                "Message length ({}) exceeds configured limit ({}). Dropping...",
-                length, M::MAX_BYTES,
+                "Message length ({length}) exceeds configured limit ({}). Dropping...",
+                M::MAX_BYTES
             );
             return Err(Error::MessageInvalid)
         }
@@ -278,8 +275,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
             Err(err) => {
                 error!(
                     target: "net::message_publisher::trigger()",
-                    "Unable to decode data. Dropping...: {}",
-                    err,
+                    "Unable to decode data. Dropping...: {err}"
                 );
                 return Err(Error::MessageInvalid)
             }

+ 1 - 1
src/net/metering.rs

@@ -97,7 +97,7 @@ impl MeteringQueue {
             // This is an edge case where system reports a future timestamp
             // therefore elapsed computation fails.
             let Ok(elapsed) = ts.elapsed() else {
-                debug!(target: "net::metering::MeteringQueue::clean()", "Timestamp [{}] is in future. Removing...", ts);
+                debug!(target: "net::metering::MeteringQueue::clean()", "Timestamp [{ts}] is in future. Removing...");
                 let _ = self.queue.pop_front();
                 continue
             };

+ 3 - 3
src/net/p2p.rs

@@ -129,7 +129,7 @@ impl P2p {
 
         // Start the inbound session
         if let Err(err) = self.session_inbound().start().await {
-            error!(target: "net::p2p::start", "Failed to start inbound session!: {}", err);
+            error!(target: "net::p2p::start", "Failed to start inbound session!: {err}");
             return Err(err)
         }
 
@@ -301,8 +301,8 @@ async fn broadcast_serialized_to<M: Message>(
                 .map_err(|e| {
                     error!(
                         target: "net::p2p::broadcast()",
-                        "[P2P] Broadcasting message to {} failed: {}",
-                        channel.address(), e
+                        "[P2P] Broadcasting message to {} failed: {e}",
+                        channel.address()
                     );
                     // If the channel is stopped then it should automatically die
                     // and the session will remove it from p2p.

+ 2 - 2
src/net/protocol/protocol_jobs_manager.rs

@@ -85,9 +85,9 @@ impl ProtocolJobsManager {
         let mut i = 0;
         #[allow(clippy::explicit_counter_loop)]
         for task in tasks {
-            trace!(target: "net::protocol_jobs_manager", "Cancelling task #{}", i);
+            trace!(target: "net::protocol_jobs_manager", "Cancelling task #{i}");
             let _ = task.cancel().await;
-            trace!(target: "net::protocol_jobs_manager", "Cancelled task #{}", i);
+            trace!(target: "net::protocol_jobs_manager", "Cancelled task #{i}");
             i += 1;
         }
     }

+ 6 - 6
src/net/protocol/protocol_version.rs

@@ -86,8 +86,8 @@ impl ProtocolVersion {
             Either::Left((Err(e), _)) => {
                 error!(
                     target: "net::protocol_version::run()",
-                    "[P2P] Version Exchange failed [{}]: {}",
-                    self.channel.address(), e,
+                    "[P2P] Version Exchange failed [{}]: {e}",
+                    self.channel.address()
                 );
 
                 self.channel.stop().await;
@@ -121,7 +121,7 @@ impl ProtocolVersion {
         if let Err(e) = &rets[0] {
             error!(
                 target: "net::protocol_version::exchange_versions()",
-                "send_version() failed: {}", e,
+                "send_version() failed: {e}"
             );
             return Err(e.clone())
         }
@@ -129,7 +129,7 @@ impl ProtocolVersion {
         if let Err(e) = &rets[1] {
             error!(
                 target: "net::protocol_version::exchange_versions()",
-                "recv_version() failed: {}", e,
+                "recv_version() failed: {e}"
             );
             return Err(e.clone())
         }
@@ -176,8 +176,8 @@ impl ProtocolVersion {
         // Validate peer received version against our version.
         debug!(
             target: "net::protocol_version::send_version()",
-            "App version: {}, Recv version: {}",
-            app_version, verack_msg.app_version,
+            "App version: {app_version}, Recv version: {}",
+            verack_msg.app_version,
         );
 
         // MAJOR and MINOR should be the same.

+ 4 - 4
src/net/session/inbound_session.rs

@@ -137,11 +137,11 @@ impl InboundSession {
         acceptor: AcceptorPtr,
         ex: Arc<Executor<'_>>,
     ) -> Result<()> {
-        info!(target: "net::inbound_session", "[P2P] Starting Inbound session #{} on {}", index, accept_addr);
+        info!(target: "net::inbound_session", "[P2P] Starting Inbound session #{index} on {accept_addr}");
         // Start listener
         let result = acceptor.clone().start(accept_addr, ex).await;
         if let Err(e) = &result {
-            error!(target: "net::inbound_session", "[P2P] Error starting listener #{}: {}", index, e);
+            error!(target: "net::inbound_session", "[P2P] Error starting listener #{index}: {e}");
             acceptor.stop().await;
         } else {
             self.acceptors.lock().await.push(acceptor);
@@ -176,7 +176,7 @@ impl InboundSession {
     ) {
         info!(
              target: "net::inbound_session::setup_channel",
-             "[P2P] Connected Inbound #{} [{}]", index, channel.address(),
+             "[P2P] Connected Inbound #{index} [{}]", channel.address()
         );
 
         dnetev!(self, InboundConnected, {
@@ -201,7 +201,7 @@ impl InboundSession {
             Err(e) => {
                 warn!(
                     target: "net::inbound_session::setup_channel()",
-                    "Channel setup failed! Err={}", e
+                    "Channel setup failed! Err={e}"
                 );
             }
         }

+ 8 - 8
src/net/session/manual_session.rs

@@ -138,7 +138,7 @@ impl Slot {
             |res| async {
                 match res {
                     Ok(()) | Err(Error::NetworkServiceStopped) => {}
-                    Err(e) => error!("net::manual_session {}", e),
+                    Err(e) => error!("net::manual_session {e}"),
                 }
             },
             Error::NetworkServiceStopped,
@@ -177,7 +177,7 @@ impl Slot {
 
             if let Err(e) = self.p2p().hosts().try_register(self.addr.clone(), HostState::Connect) {
                 debug!(target: "net::manual_session",
-                    "Cannot connect to manual={}, err={}", &self.addr, e);
+                    "Cannot connect to manual={}, err={e}", &self.addr);
 
                 sleep(outbound_connect_timeout).await;
 
@@ -188,7 +188,7 @@ impl Slot {
                 Ok((url, channel)) => {
                     info!(
                         target: "net::manual_session",
-                        "[P2P] Manual outbound connected [{}]", url,
+                        "[P2P] Manual outbound connected [{url}]"
                     );
 
                     let stop_sub = channel.subscribe_stop().await?;
@@ -203,7 +203,7 @@ impl Slot {
 
                             info!(
                                 target: "net::manual_session",
-                                "[P2P] Manual outbound disconnected [{}]", url,
+                                "[P2P] Manual outbound disconnected [{url}]"
                             );
                         }
                         Err(e) => {
@@ -218,8 +218,8 @@ impl Slot {
 
             info!(
                 target: "net::manual_session",
-                "[P2P] Waiting {} seconds until next manual outbound connection attempt [{}]",
-                outbound_connect_timeout, self.addr,
+                "[P2P] Waiting {outbound_connect_timeout} seconds until next manual outbound connection attempt [{}]",
+                self.addr,
             );
 
             sleep(outbound_connect_timeout).await;
@@ -229,8 +229,8 @@ impl Slot {
     fn handle_failure(&self, error: Error, addr: &Url) {
         warn!(
             target: "net::manual_session",
-            "[P2P] Unable to connect to manual outbound [{}]: {}",
-            self.addr, error,
+            "[P2P] Unable to connect to manual outbound [{}]: {error}",
+            self.addr
         );
 
         // Free up this addr for future operations.

+ 5 - 5
src/net/session/mod.rs

@@ -68,14 +68,14 @@ pub async fn remove_sub_on_stop(
 
     debug!(
         target: "net::session::remove_sub_on_stop()",
-        "Received stop event. Removing channel {}", addr,
+        "Received stop event. Removing channel {addr}"
     );
 
     // Downgrade to greylist if this is a outbound session.
     if type_id & SESSION_OUTBOUND != 0 {
         debug!(
             target: "net::session::remove_sub_on_stop()",
-            "Downgrading {}", addr,
+            "Downgrading {addr}"
         );
 
         // If the host we are downgrading has been moved to blacklist,
@@ -85,12 +85,12 @@ pub async fn remove_sub_on_stop(
             Some(last_seen) => {
                 if let Err(e) = hosts.move_host(addr, last_seen, HostColor::Grey) {
                     error!(target: "net::session::remove_sub_on_stop()",
-            "Failed to move host {} to Greylist! Err={}", addr.clone(), e);
+            "Failed to move host {} to Greylist! Err={e}", addr.clone());
                 }
             }
             None => {
                 error!(target: "net::session::remove_sub_on_stop()",
-               "Failed to fetch last seen for {}", addr);
+               "Failed to fetch last seen for {addr}");
             }
         }
     }
@@ -158,7 +158,7 @@ pub trait Session: Sync {
             }
             Err(e) => {
                 debug!(target: "net::session::register_channel()",
-                "Handshake error {} {}", e, channel.clone().address());
+                "Handshake error {e} {}", channel.clone().address());
 
                 return Err(e)
             }

+ 10 - 15
src/net/session/outbound_session.rs

@@ -81,7 +81,7 @@ impl OutboundSession {
     /// Start the outbound session. Runs the channel connect loop.
     pub(crate) async fn start(self: Arc<Self>) {
         let n_slots = self.p2p().settings().read().await.outbound_connections;
-        info!(target: "net::outbound_session", "[P2P] Starting {} outbound connection slots.", n_slots);
+        info!(target: "net::outbound_session", "[P2P] Starting {n_slots} outbound connection slots.");
 
         // Activate mutex lock on connection slots.
         let mut slots = self.slots.lock().await;
@@ -181,7 +181,7 @@ impl Slot {
             |res| async {
                 match res {
                     Ok(()) | Err(Error::NetworkServiceStopped) => {}
-                    Err(e) => error!("net::outbound_session {}", e),
+                    Err(e) => error!("net::outbound_session {e}"),
                 }
             },
             Error::NetworkServiceStopped,
@@ -300,8 +300,7 @@ impl Slot {
 
             info!(
                 target: "net::outbound_session::try_connect()",
-                "[P2P] Connecting outbound slot #{} [{}]",
-                slot, host,
+                "[P2P] Connecting outbound slot #{slot} [{host}]"
             );
 
             dnetev!(self, OutboundSlotConnecting, {
@@ -314,8 +313,7 @@ impl Slot {
                 Err(err) => {
                     debug!(
                         target: "net::outbound_session::try_connect()",
-                        "[P2P] Outbound slot #{} connection failed: {}",
-                        slot, err
+                        "[P2P] Outbound slot #{slot} connection failed: {err}"
                     );
 
                     dnetev!(self, OutboundSlotDisconnected, {
@@ -334,8 +332,7 @@ impl Slot {
 
             info!(
                 target: "net::outbound_session::try_connect()",
-                "[P2P] Outbound slot #{} connected [{}]",
-                slot, addr
+                "[P2P] Outbound slot #{slot} connected [{addr}]"
             );
 
             dnetev!(self, OutboundSlotConnected, {
@@ -350,8 +347,7 @@ impl Slot {
             {
                 info!(
                     target: "net::outbound_session",
-                    "[P2P] Outbound slot #{} disconnected: {}",
-                    slot, err
+                    "[P2P] Outbound slot #{slot} disconnected: {err}"
                 );
 
                 dnetev!(self, OutboundSlotDisconnected, {
@@ -363,8 +359,7 @@ impl Slot {
 
                 warn!(
                     target: "net::outbound_session::try_connect()",
-                    "[P2P] Suspending addr=[{}] slot #{}",
-                    addr, slot
+                    "[P2P] Suspending addr=[{addr}] slot #{slot}"
                 );
 
                 // Peer disconnected during the registry process. We'll downgrade this peer now.
@@ -399,8 +394,8 @@ impl Slot {
             Err(err) => {
                 info!(
                     target: "net::outbound_session::try_connect()",
-                    "[P2P] Unable to connect outbound slot #{} [{}]: {}",
-                    self.slot, addr, err
+                    "[P2P] Unable to connect outbound slot #{} [{addr}]: {err}",
+                    self.slot
                 );
 
                 // Immediately return if the Connector has stopped.
@@ -588,7 +583,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
                     Ok(addrs_len) => {
                         info!(
                             target: "net::outbound_session::peer_discovery()",
-                            "[P2P] [PEER DISCOVERY] Discovered {} peers", addrs_len
+                            "[P2P] [PEER DISCOVERY] Discovered {addrs_len} peers"
                         );
                     }
                     Err(_) => {

+ 14 - 14
src/net/session/refine_session.rs

@@ -75,7 +75,7 @@ impl RefineSession {
                     debug!(target: "net::refine_session::start", "Load hosts successful!");
                 }
                 Err(e) => {
-                    warn!(target: "net::refine_session::start", "Error loading hosts {}", e);
+                    warn!(target: "net::refine_session::start", "Error loading hosts {e}");
                 }
             }
         }
@@ -86,7 +86,7 @@ impl RefineSession {
             }
             Err(e) => {
                 warn!(target: "net::refine_session::start",
-                    "Error importing blacklist from config file {}", e);
+                    "Error importing blacklist from config file {e}");
             }
         }
 
@@ -105,7 +105,7 @@ impl RefineSession {
                     debug!(target: "net::refine_session::stop()", "Save hosts successful!");
                 }
                 Err(e) => {
-                    warn!(target: "net::refine_session::stop()", "Error saving hosts {}", e);
+                    warn!(target: "net::refine_session::stop()", "Error saving hosts {e}");
                 }
             }
         }
@@ -118,19 +118,19 @@ impl RefineSession {
         let self_ = Arc::downgrade(&self);
         let connector = Connector::new(self.p2p().settings(), self_);
 
-        debug!(target: "net::refinery::handshake_node()", "Attempting to connect to {}", addr);
+        debug!(target: "net::refinery::handshake_node()", "Attempting to connect to {addr}");
         match connector.connect(&addr).await {
             Ok((url, channel)) => {
-                debug!(target: "net::refinery::handshake_node()", "Successfully created a channel with {}", url);
+                debug!(target: "net::refinery::handshake_node()", "Successfully created a channel with {url}");
                 // First initialize the version protocol and its Version, Verack subscriptions.
                 let proto_ver = ProtocolVersion::new(channel.clone(), p2p.settings()).await;
 
-                debug!(target: "net::refinery::handshake_node()", "Performing handshake protocols with {}", url);
+                debug!(target: "net::refinery::handshake_node()", "Performing handshake protocols with {url}");
                 // Then run the version exchange, store the channel and subscribe to a stop signal.
                 let handshake =
                     self.perform_handshake_protocols(proto_ver, channel.clone(), p2p.executor());
 
-                debug!(target: "net::refinery::handshake_node()", "Starting channel {}", url);
+                debug!(target: "net::refinery::handshake_node()", "Starting channel {url}");
                 channel.clone().start(p2p.executor());
 
                 // Ensure the channel gets stopped by adding a timeout to the handshake. Otherwise if
@@ -147,7 +147,7 @@ impl RefineSession {
                         true
                     }
                     Either::Left((Err(e), _)) => {
-                        debug!(target: "net::refinery::handshake_node()", "Handshake error={}", e);
+                        debug!(target: "net::refinery::handshake_node()", "Handshake error={e}");
                         false
                     }
                     Either::Right((_, _)) => {
@@ -156,14 +156,14 @@ impl RefineSession {
                     }
                 };
 
-                debug!(target: "net::refinery::handshake_node()", "Stopping channel {}", url);
+                debug!(target: "net::refinery::handshake_node()", "Stopping channel {url}");
                 channel.stop().await;
 
                 result
             }
 
             Err(e) => {
-                debug!(target: "net::refinery::handshake_node()", "Failed to connect to {}, ({})", addr, e);
+                debug!(target: "net::refinery::handshake_node()", "Failed to connect to {addr}, ({e})");
                 false
             }
         }
@@ -270,8 +270,8 @@ impl GreylistRefinery {
                     let url = &entry.0;
 
                     if let Err(e) = hosts.try_register(url.clone(), HostState::Refine) {
-                        debug!(target: "net::refinery", "Unable to refine addr={}, err={}",
-                               url.clone(), e);
+                        debug!(target: "net::refinery", "Unable to refine addr={}, err={e}",
+                               url.clone());
                         continue
                     }
 
@@ -280,7 +280,7 @@ impl GreylistRefinery {
 
                         debug!(
                             target: "net::refinery",
-                            "Peer {} handshake failed. Removed from greylist", url,
+                            "Peer {url} handshake failed. Removed from greylist"
                         );
 
                         // Free up this addr for future operations.
@@ -290,7 +290,7 @@ impl GreylistRefinery {
                     }
                     debug!(
                         target: "net::refinery",
-                        "Peer {} handshake successful. Adding to whitelist", url,
+                        "Peer {url} handshake successful. Adding to whitelist"
                     );
                     let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
 

+ 5 - 6
src/net/session/seedsync_session.rs

@@ -204,7 +204,7 @@ impl Slot {
 
             if let Err(e) = hosts.try_register(self.addr.clone(), HostState::Connect) {
                 debug!(target: "net::session::seedsync_session",
-                    "Cannot connect to seed={}, err={}", &self.addr, e);
+                    "Cannot connect to seed={}, err={e}", &self.addr);
 
                 // Reset the CondVar for future use.
                 self.reset();
@@ -216,7 +216,7 @@ impl Slot {
                 Ok((url, ch)) => {
                     info!(
                         target: "net::session::seedsync_session",
-                        "[P2P] Connected seed [{}]", url,
+                        "[P2P] Connected seed [{url}]",
                     );
 
                     match self.session().register_channel(ch.clone(), ex.clone()).await {
@@ -225,8 +225,7 @@ impl Slot {
 
                             info!(
                                 target: "net::session::seedsync_session",
-                                "[P2P] Disconnecting from seed [{}]",
-                                url,
+                                "[P2P] Disconnecting from seed [{url}]"
                             );
                             ch.stop().await;
 
@@ -264,8 +263,8 @@ impl Slot {
     fn handle_failure(&self, error: Error, addr: &Url) {
         warn!(
             target: "net::session::seedsync_session",
-            "[P2P] Unable to connect to seed [{}]: {}",
-            self.addr, error,
+            "[P2P] Unable to connect to seed [{}]: {error}",
+            self.addr
         );
 
         self.failed.store(true, SeqCst);

+ 13 - 13
src/net/tests.rs

@@ -99,8 +99,8 @@ async fn spawn_seed_session(seed_addr: Url, ex: Arc<Executor<'static>>) -> Vec<A
     for port in ports {
         let settings = Settings {
             localnet: true,
-            inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", port)).unwrap()],
-            external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", port)).unwrap()],
+            inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{port}")).unwrap()],
+            external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{port}")).unwrap()],
             outbound_connections: 2,
             outbound_peer_discovery_cooloff_time: 2,
             outbound_connect_timeout: 2,
@@ -137,14 +137,14 @@ async fn spawn_manual_session(ex: Arc<Executor<'static>>) -> Vec<Arc<P2p>> {
         let mut peers = vec![];
         for &peer_index in peer_indexes_to_connect {
             let port = ports[peer_index];
-            peers.push(Url::parse(&format!("tcp://127.0.0.1:{}", port)).unwrap());
+            peers.push(Url::parse(&format!("tcp://127.0.0.1:{port}")).unwrap());
         }
 
         let inbound_port = ports[i];
         let settings = Settings {
             localnet: true,
-            inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", inbound_port)).unwrap()],
-            external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", inbound_port)).unwrap()],
+            inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{inbound_port}")).unwrap()],
+            external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{inbound_port}")).unwrap()],
             outbound_connections: 2,
             outbound_peer_discovery_cooloff_time: 2,
             outbound_connect_timeout: 2,
@@ -172,7 +172,7 @@ async fn get_random_gold_host(
     let external_addr = random_node.settings().read().await.external_addrs[0].clone();
 
     info!("========================================================");
-    info!("Getting gold addr from node={}", external_addr);
+    info!("Getting gold addr from node={external_addr}");
     info!("========================================================");
 
     let list = hosts.container.hostlists[HostColor::Gold as usize].read().unwrap();
@@ -188,7 +188,7 @@ async fn _check_random_hostlist(outbound_instances: &[Arc<P2p>], rng: &mut Threa
     let external_addr = random_node.settings().read().await.external_addrs[0].clone();
 
     info!("========================================================");
-    info!("Checking node={}", external_addr);
+    info!("Checking node={external_addr}");
     info!("========================================================");
 
     let greylist = random_node.hosts().container.fetch_all(HostColor::Grey);
@@ -211,7 +211,7 @@ async fn check_all_hostlist(outbound_instances: &Vec<Arc<P2p>>) {
     for node in outbound_instances {
         let external_addr = &node.settings().read().await.external_addrs[0].clone();
         info!("========================================================");
-        info!("Checking node={}", external_addr);
+        info!("Checking node={external_addr}");
         info!("========================================================");
 
         let mut urls = HashSet::new();
@@ -284,7 +284,7 @@ async fn p2p_test_real(ex: Arc<Executor<'static>>) {
     // 1. Create a new seed node.
     // ============================================================
     let seed_port = get_random_available_port();
-    let seed_addr = Url::parse(&format!("tcp://127.0.0.1:{}", seed_port)).unwrap();
+    let seed_addr = Url::parse(&format!("tcp://127.0.0.1:{seed_port}")).unwrap();
 
     let settings = Settings {
         localnet: true,
@@ -301,7 +301,7 @@ async fn p2p_test_real(ex: Arc<Executor<'static>>) {
 
     let seed = P2p::new(settings, ex.clone()).await.unwrap();
     info!("========================================================");
-    info!("Starting seed node on {}", seed_addr);
+    info!("Starting seed node on {seed_addr}");
     info!("========================================================");
     seed.clone().start().await.unwrap();
 
@@ -353,15 +353,15 @@ async fn p2p_test_real(ex: Arc<Executor<'static>>) {
     let goldlist = seed.hosts().container.fetch_all(HostColor::Gold);
 
     for (url, _) in greylist {
-        info!("Found grey url: {}", url);
+        info!("Found grey url: {url}");
         assert!(urls.insert(url));
     }
     for (url, _) in whitelist {
-        info!("Found white url: {}", url);
+        info!("Found white url: {url}");
         assert!(urls.insert(url));
     }
     for (url, _) in goldlist {
-        info!("Found gold url: {}", url);
+        info!("Found gold url: {url}");
         assert!(urls.insert(url));
     }
     assert!(!urls.is_empty());

+ 2 - 2
src/net/transport/mod.rs

@@ -244,7 +244,7 @@ impl Dialer {
             }
 
             x => {
-                error!("[P2P] Requested unsupported transport: {}", x);
+                error!("[P2P] Requested unsupported transport: {x}");
                 Err(io::Error::from_raw_os_error(libc::ENETUNREACH))
             }
         }
@@ -379,7 +379,7 @@ impl Listener {
             }
 
             x => {
-                error!("[P2P] Requested unsupported transport: {}", x);
+                error!("[P2P] Requested unsupported transport: {x}");
                 Err(io::Error::from_raw_os_error(libc::ENETUNREACH))
             }
         }

+ 1 - 1
src/net/transport/socks5.rs

@@ -145,7 +145,7 @@ impl Socks5Client {
         stream.flush().await?;
         debug!(
             target: "net::transport::socks5::connect",
-            "Flushed CONNECT({:?}) request", addr,
+            "Flushed CONNECT({addr:?}) request"
         );
 
         // Handle the SOCKS server reply

+ 3 - 3
src/net/transport/tcp.rs

@@ -92,7 +92,7 @@ impl TcpDialer {
         socket_addr: SocketAddr,
         timeout: Option<Duration>,
     ) -> io::Result<TcpStream> {
-        debug!(target: "net::tcp::do_dial", "Dialing {} with TCP...", socket_addr);
+        debug!(target: "net::tcp::do_dial", "Dialing {socket_addr} with TCP...");
         let socket = self.create_socket(socket_addr).await?;
 
         socket.set_nonblocking(true)?;
@@ -198,7 +198,7 @@ impl PtListener for SmolTcpListener {
             Err(e) => return Err(e),
         };
 
-        let url = Url::parse(&format!("tcp://{}", peer_addr)).unwrap();
+        let url = Url::parse(&format!("tcp://{peer_addr}")).unwrap();
         Ok((Box::new(stream), url))
     }
 }
@@ -216,7 +216,7 @@ impl PtListener for (TlsAcceptor, SmolTcpListener) {
             Err(e) => return Err(e),
         };
 
-        let url = Url::parse(&format!("tcp+tls://{}", peer_addr)).unwrap();
+        let url = Url::parse(&format!("tcp+tls://{peer_addr}")).unwrap();
 
         Ok((Box::new(TlsStream::Server(stream)), url))
     }

+ 2 - 2
src/net/transport/tls.rs

@@ -139,7 +139,7 @@ impl ServerCertVerifier for ServerCertificateVerifier {
         };
 
         if let Err(e) = public_key.verify(message, &signature) {
-            error!(target: "net::tls::verify_tls13_signature", "[net::tls] Failed verifying server signature: {}", e);
+            error!(target: "net::tls::verify_tls13_signature", "[net::tls] Failed verifying server signature: {e}");
             return Err(rustls::CertificateError::BadSignature.into())
         }
 
@@ -234,7 +234,7 @@ impl ClientCertVerifier for ClientCertificateVerifier {
         };
 
         if let Err(e) = public_key.verify(message, &signature) {
-            error!(target: "net::tls::verify_tls13_signature", "[net::tls] Failed verifying server signature: {}", e);
+            error!(target: "net::tls::verify_tls13_signature", "[net::tls] Failed verifying server signature: {e}");
             return Err(rustls::CertificateError::BadSignature.into())
         }
 

+ 8 - 8
src/net/transport/tor.rs

@@ -116,7 +116,7 @@ impl TorDialer {
         port: u16,
         conn_timeout: Option<Duration>,
     ) -> io::Result<DataStream> {
-        debug!(target: "net::tor::do_dial", "Dialing {}:{} with Tor...", host, port);
+        debug!(target: "net::tor::do_dial", "Dialing {host}:{port} with Tor...");
 
         let mut stream_prefs = StreamPrefs::new();
         stream_prefs.connect_to_onion_services(BoolOrAuto::Explicit(true));
@@ -219,7 +219,7 @@ impl TorListener {
             Err(e) => {
                 error!(
                     target: "net::tor::do_listen",
-                    "[P2P] Failed to create OnionServiceConfig: {}", e,
+                    "[P2P] Failed to create OnionServiceConfig: {e}"
                 );
                 return Err(io::Error::other("Internal Tor error"));
             }
@@ -230,7 +230,7 @@ impl TorListener {
             Err(e) => {
                 error!(
                     target: "net::tor::do_listen",
-                    "[P2P] Failed to launch Onion Service: {}", e,
+                    "[P2P] Failed to launch Onion Service: {e}"
                 );
                 return Err(io::Error::other("Internal Tor error"));
             }
@@ -238,12 +238,12 @@ impl TorListener {
 
         info!(
             target: "net::tor::do_listen",
-            "[P2P] Established Tor listener on tor://{}:{}",
-            onion_service.onion_address().unwrap(), port,
+            "[P2P] Established Tor listener on tor://{}:{port}",
+            onion_service.onion_address().unwrap()
         );
 
         let endpoint =
-            Url::parse(&format!("tor://{}:{}", onion_service.onion_address().unwrap(), port))
+            Url::parse(&format!("tor://{}:{port}", onion_service.onion_address().unwrap()))
                 .unwrap();
         self.endpoint.set(endpoint).await.expect("fatal endpoint already set for TorListener");
 
@@ -281,7 +281,7 @@ impl PtListener for TorListenerIntern {
             Err(e) => {
                 error!(
                     target: "net::tor::PtListener::next",
-                    "[P2P] Failed accepting Tor RendRequest: {}", e,
+                    "[P2P] Failed accepting Tor RendRequest: {e}"
                 );
                 return Err(io::Error::new(ErrorKind::ConnectionAborted, "Connection Aborted"));
             }
@@ -306,7 +306,7 @@ impl PtListener for TorListenerIntern {
             Err(e) => {
                 error!(
                     target: "net::tor::PtListener::next",
-                    "[P2P] Failed accepting Tor StreamRequest: {}", e,
+                    "[P2P] Failed accepting Tor StreamRequest: {e}"
                 );
                 return Err(io::Error::other("Internal Tor error"));
             }

+ 2 - 2
src/net/transport/unix.rs

@@ -46,7 +46,7 @@ impl UnixDialer {
         &self,
         path: impl AsRef<Path> + core::fmt::Debug,
     ) -> io::Result<UnixStream> {
-        debug!(target: "net::unix::do_dial", "Dialing {:?} Unix socket...", path);
+        debug!(target: "net::unix::do_dial", "Dialing {path:?} Unix socket...");
         let stream = UnixStream::connect(path).await?;
         Ok(stream)
     }
@@ -81,7 +81,7 @@ impl PtListener for SmolUnixListener {
 
         let addr = self.local_addr().unwrap();
         let addr = addr.as_pathname().unwrap().to_str().unwrap();
-        let url = Url::parse(&format!("unix://{}", addr)).unwrap();
+        let url = Url::parse(&format!("unix://{addr}")).unwrap();
 
         Ok((Box::new(stream), url))
     }