Просмотр исходного кода

net: fix warnings and cargo fmt

lunar-mining 2 лет назад
Родитель
Сommit
066d3dc9c5

+ 5 - 21
src/net/hosts/refinery.rs

@@ -16,36 +16,21 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use std::{
-    collections::HashSet,
-    sync::{Arc, Weak},
-    time::UNIX_EPOCH,
-};
-
-use log::{debug, trace, warn};
-use rand::{
-    prelude::{IteratorRandom, SliceRandom},
-    rngs::OsRng,
-};
+use std::{sync::Arc, time::UNIX_EPOCH};
 
+use log::{debug, warn};
 use rand::Rng;
-use smol::lock::RwLock;
 use url::Url;
 
-use super::super::{
-    p2p::{P2p, P2pPtr},
-    settings::SettingsPtr,
-};
+use super::super::p2p::P2pPtr;
 use crate::{
     net::{
         connector::Connector,
         protocol::ProtocolVersion,
         session::{Session, SessionWeakPtr},
     },
-    system::{
-        sleep, LazyWeak, StoppableTask, StoppableTaskPtr, Subscriber, SubscriberPtr, Subscription,
-    },
-    Error, Result,
+    system::{sleep, StoppableTask, StoppableTaskPtr},
+    Error,
 };
 
 //// Probe random peers on the greylist. If a peer is responsive, update the last_seen field and
@@ -87,7 +72,6 @@ impl GreylistRefinery {
         debug!(target: "net::refinery::run()", "START");
         loop {
             let hosts = self.p2p.hosts();
-            let session = self.p2p.session_outbound();
 
             if hosts.is_empty_greylist().await {
                 warn!(target: "net::refinery::run()", "Greylist is empty. Aborting");

+ 2 - 2
src/net/hosts/store.rs

@@ -475,7 +475,7 @@ impl Hosts {
     }
 
     /// Get the index for a given addr on the whitelist.
-    pub async fn get_whitelist_index_at_addr(&self, addr: &Url) -> Result<(usize)> {
+    pub async fn get_whitelist_index_at_addr(&self, addr: &Url) -> Result<usize> {
         let whitelist = self.whitelist.read().await;
         for (i, (url, _time)) in whitelist.iter().enumerate() {
             if url == addr {
@@ -486,7 +486,7 @@ impl Hosts {
     }
 
     /// Get the index for a given addr on the greylist.
-    pub async fn get_greylist_index_at_addr(&self, addr: &Url) -> Result<(usize)> {
+    pub async fn get_greylist_index_at_addr(&self, addr: &Url) -> Result<usize> {
         let greylist = self.greylist.read().await;
         for (i, (url, _time)) in greylist.iter().enumerate() {
             if url == addr {

+ 1 - 2
src/net/protocol/protocol_seed.rs

@@ -34,8 +34,7 @@ use super::{
     },
     protocol_base::{ProtocolBase, ProtocolBasePtr},
 };
-use crate::Result;
-use crate::net::hosts::refinery::ping_node;
+use crate::{net::hosts::refinery::ping_node, Result};
 
 /// Implements the seed protocol
 pub struct ProtocolSeed {

+ 0 - 2
src/net/session/outbound_session.rs

@@ -36,7 +36,6 @@ use std::{
 
 use async_trait::async_trait;
 use log::{debug, error, info, warn};
-use rand::Rng;
 use smol::lock::Mutex;
 use url::Url;
 
@@ -47,7 +46,6 @@ use super::{
         dnet::{self, dnetev, DnetEvent},
         message::GetAddrsMessage,
         p2p::{P2p, P2pPtr},
-        protocol::ProtocolVersion,
     },
     Session, SessionBitFlag, SESSION_OUTBOUND,
 };