narodnik 4 лет назад
Родитель
Сommit
6fb1304c00

+ 6 - 8
bin/map/src/main.rs

@@ -120,14 +120,12 @@ async fn poll(client: Map, app: App) -> Result<()> {
             let node2 = &nodes[1];
             let node3 = &nodes[2];
 
-            let infos = vec![
-                NodeInfo {
-                    id: node1["id"].to_string(),
-                    connections: node1["connections"].as_u64().unwrap() as usize,
-                    is_active: node2["is_active"].as_bool().unwrap(),
-                    last_message: node3["message"].to_string(),
-                },
-            ];
+            let infos = vec![NodeInfo {
+                id: node1["id"].to_string(),
+                connections: node1["connections"].as_u64().unwrap() as usize,
+                is_active: node2["is_active"].as_bool().unwrap(),
+                last_message: node3["message"].to_string(),
+            }];
 
             app.clone().update(infos).await;
         } else {

+ 1 - 1
src/net/channel.rs

@@ -16,8 +16,8 @@ use std::sync::{
 use crate::{
     error::{Error, Result},
     net::{
-        message_subscriber::{MessageSubscription, MessageSubsystem},
         message,
+        message_subscriber::{MessageSubscription, MessageSubsystem},
         protocol::{ProtocolBase, ProtocolBasePtr},
     },
     system::{StoppableTask, StoppableTaskPtr, Subscriber, SubscriberPtr, Subscription},

+ 1 - 1
src/net/mod.rs

@@ -89,8 +89,8 @@ pub use acceptor::{Acceptor, AcceptorPtr};
 pub use channel::{Channel, ChannelPtr};
 pub use connector::Connector;
 pub use hosts::{Hosts, HostsPtr};
-pub use message_subscriber::MessageSubscription;
 pub use message::Message;
+pub use message_subscriber::MessageSubscription;
 pub use p2p::{P2p, P2pPtr};
 pub use protocol::{ProtocolJobsManager, ProtocolJobsManagerPtr};
 pub use settings::{Settings, SettingsPtr};

+ 3 - 4
src/net/protocol/protocol_address.rs

@@ -1,13 +1,13 @@
-use log::{error, debug};
+use async_trait::async_trait;
+use log::{debug, error};
 use smol::Executor;
 use std::sync::Arc;
-use async_trait::async_trait;
 
 use crate::{
     error::Result,
     net::{
-        message_subscriber::MessageSubscription,
         message,
+        message_subscriber::MessageSubscription,
         protocol::{ProtocolBase, ProtocolBasePtr, ProtocolJobsManager, ProtocolJobsManagerPtr},
         ChannelPtr, HostsPtr, P2pPtr,
     },
@@ -137,4 +137,3 @@ impl ProtocolBase for ProtocolAddress {
         debug!(target: "net", "ProtocolAddress::start() [END]");
     }
 }
-

+ 1 - 1
src/net/protocol/protocol_base.rs

@@ -1,6 +1,6 @@
-use std::sync::Arc;
 use async_trait::async_trait;
 use smol::Executor;
+use std::sync::Arc;
 
 pub type ProtocolBasePtr = Arc<dyn 'static + ProtocolBase + Send + Sync>;
 

+ 2 - 3
src/net/protocol/protocol_ping.rs

@@ -1,8 +1,8 @@
-use log::{error, debug};
+use async_trait::async_trait;
+use log::{debug, error};
 use rand::Rng;
 use smol::Executor;
 use std::{sync::Arc, time::Instant};
-use async_trait::async_trait;
 
 use crate::{
     error::{Error, Result},
@@ -126,4 +126,3 @@ impl ProtocolBase for ProtocolPing {
         debug!(target: "net", "ProtocolPing::start() [END]");
     }
 }
-

+ 6 - 7
src/net/protocol/protocol_registry.rs

@@ -8,10 +8,11 @@ use std::sync::Arc;
 use super::protocol_base::ProtocolBasePtr;
 use crate::net::{ChannelPtr, P2pPtr};
 
-type Constructor =
-    Box<dyn Fn(ChannelPtr, P2pPtr) -> BoxFuture<'static,
-        Arc<dyn 'static + ProtocolBase + Send + Sync>
-    > + Send + Sync>;
+type Constructor = Box<
+    dyn Fn(ChannelPtr, P2pPtr) -> BoxFuture<'static, Arc<dyn 'static + ProtocolBase + Send + Sync>>
+        + Send
+        + Sync,
+>;
 
 pub struct ProtocolRegistry {
     protocol_constructors: Mutex<Vec<Constructor>>,
@@ -19,9 +20,7 @@ pub struct ProtocolRegistry {
 
 impl ProtocolRegistry {
     pub fn new() -> Self {
-        Self {
-            protocol_constructors: Mutex::new(Vec::new()),
-        }
+        Self { protocol_constructors: Mutex::new(Vec::new()) }
     }
 
     // add_protocol()?

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

@@ -5,7 +5,7 @@ use std::sync::Arc;
 
 use crate::{
     error::{Error, Result},
-    net::{message_subscriber::MessageSubscription, message, ChannelPtr, SettingsPtr},
+    net::{message, message_subscriber::MessageSubscription, ChannelPtr, SettingsPtr},
     util::sleep,
 };
 

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

@@ -8,7 +8,7 @@ use std::{
 use crate::{
     error::{Error, Result},
     net::{
-        protocol::{ProtocolAddress, ProtocolPing, ProtocolBase},
+        protocol::{ProtocolAddress, ProtocolBase, ProtocolPing},
         session::Session,
         Acceptor, AcceptorPtr, ChannelPtr, P2p,
     },

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

@@ -9,7 +9,7 @@ use std::{
 use crate::{
     error::{Error, Result},
     net::{
-        protocol::{ProtocolAddress, ProtocolPing, ProtocolBase},
+        protocol::{ProtocolAddress, ProtocolBase, ProtocolPing},
         session::Session,
         ChannelPtr, Connector, P2p,
     },

+ 1 - 1
src/net/session/outbound_session.rs

@@ -9,7 +9,7 @@ use std::{
 use crate::{
     error::{Error, Result},
     net::{
-        protocol::{ProtocolAddress, ProtocolPing, ProtocolBase},
+        protocol::{ProtocolAddress, ProtocolBase, ProtocolPing},
         session::Session,
         ChannelPtr, Connector, P2p,
     },

+ 1 - 1
src/net/session/seed_session.rs

@@ -9,7 +9,7 @@ use std::{
 use crate::{
     error::{Error, Result},
     net::{
-        protocol::{ProtocolPing, ProtocolSeed, ProtocolBase},
+        protocol::{ProtocolBase, ProtocolPing, ProtocolSeed},
         session::Session,
         ChannelPtr, Connector, HostsPtr, P2p, SettingsPtr,
     },