Browse Source

net: minor changes

ghassmo 4 years ago
parent
commit
891add8c62
2 changed files with 22 additions and 24 deletions
  1. 2 2
      src/net/p2p.rs
  2. 20 22
      src/net/session/seed_session.rs

+ 2 - 2
src/net/p2p.rs

@@ -20,7 +20,7 @@ use crate::{
 /// List of channels that are awaiting connection.
 pub type PendingChannels = Mutex<FxHashSet<SocketAddr>>;
 /// List of connected channels.
-pub type ConnectedChannels<T> = Mutex<fxhash::FxHashMap<SocketAddr, Arc<T>>>;
+pub type ConnectedChannels = Mutex<fxhash::FxHashMap<SocketAddr, Arc<Channel>>>;
 /// Atomic pointer to p2p interface.
 pub type P2pPtr = Arc<P2p>;
 
@@ -53,7 +53,7 @@ impl fmt::Display for P2pState {
 /// Top level peer-to-peer networking interface.
 pub struct P2p {
     pending: PendingChannels,
-    channels: ConnectedChannels<Channel>,
+    channels: ConnectedChannels,
     channel_subscriber: SubscriberPtr<Result<ChannelPtr>>,
     // Used both internally and externally
     stop_subscriber: SubscriberPtr<Error>,

+ 20 - 22
src/net/session/seed_session.rs

@@ -62,12 +62,10 @@ impl SeedSession {
                 }
             })
             .await;
-        match result {
-            Ok(_) => {}
-            Err(_) => {
-                error!("Querying seeds timed out");
-                return Err(Error::OperationFailed)
-            }
+
+        if let Err(_) = result {
+            error!("Querying seeds timed out");
+            return Err(Error::OperationFailed)
         }
 
         // Seed process complete
@@ -118,22 +116,22 @@ impl SeedSession {
 
     // Starts keep-alive messages and seed protocol.
     /*async fn attach_protocols(
-        self: Arc<Self>,
-        channel: ChannelPtr,
-        hosts: HostsPtr,
-        settings: SettingsPtr,
-        executor: Arc<Executor<'_>>,
-    ) -> Result<()> {
-        let protocol_ping = ProtocolPing::new(channel.clone(), self.p2p());
-        protocol_ping.start(executor.clone()).await;
-
-        let protocol_seed = ProtocolSeed::new(channel.clone(), hosts, settings.clone());
-        // This will block until seed process is complete
-        protocol_seed.start(executor.clone()).await?;
-
-        channel.stop().await;
-
-        Ok(())
+      self: Arc<Self>,
+      channel: ChannelPtr,
+      hosts: HostsPtr,
+      settings: SettingsPtr,
+      executor: Arc<Executor<'_>>,
+      ) -> Result<()> {
+      let protocol_ping = ProtocolPing::new(channel.clone(), self.p2p());
+      protocol_ping.start(executor.clone()).await;
+
+      let protocol_seed = ProtocolSeed::new(channel.clone(), hosts, settings.clone());
+    // This will block until seed process is complete
+    protocol_seed.start(executor.clone()).await?;
+
+    channel.stop().await;
+
+    Ok(())
     }*/
 }