Przeglądaj źródła

delete old new() functions and rename new2() to new()

narodnik 4 lat temu
rodzic
commit
7343c0be83

+ 3 - 3
src/net/protocol/mod.rs

@@ -65,7 +65,7 @@ use crate::net::{
 
 pub async fn register_default_protocols(p2p: P2pPtr) {
     let registry = p2p.protocol_registry();
-    registry.register(SESSION_ALL, ProtocolPing::new2).await;
-    registry.register(!SESSION_SEED, ProtocolAddress::new2).await;
-    registry.register(SESSION_SEED, ProtocolSeed::new2).await;
+    registry.register(SESSION_ALL, ProtocolPing::new).await;
+    registry.register(!SESSION_SEED, ProtocolAddress::new).await;
+    registry.register(SESSION_SEED, ProtocolSeed::new).await;
 }

+ 1 - 25
src/net/protocol/protocol_address.rs

@@ -25,31 +25,7 @@ pub struct ProtocolAddress {
 impl ProtocolAddress {
     /// Create a new address protocol. Makes an address and get-address
     /// subscription and adds them to the address protocol instance.
-    pub async fn new(channel: ChannelPtr, hosts: HostsPtr) -> Arc<Self> {
-        // Creates a subscription to address message.
-        let addrs_sub = channel
-            .clone()
-            .subscribe_msg::<message::AddrsMessage>()
-            .await
-            .expect("Missing addrs dispatcher!");
-
-        // Creates a subscription to get-address message.
-        let get_addrs_sub = channel
-            .clone()
-            .subscribe_msg::<message::GetAddrsMessage>()
-            .await
-            .expect("Missing getaddrs dispatcher!");
-
-        Arc::new(Self {
-            channel: channel.clone(),
-            addrs_sub,
-            get_addrs_sub,
-            hosts,
-            jobsman: ProtocolJobsManager::new("ProtocolAddress", channel),
-        })
-    }
-
-    pub async fn new2(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
+    pub async fn new(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
         let hosts = p2p.hosts();
 
         // Creates a subscription to address message.

+ 1 - 11
src/net/protocol/protocol_ping.rs

@@ -23,17 +23,7 @@ pub struct ProtocolPing {
 
 impl ProtocolPing {
     /// Create a new ping-pong protocol.
-    pub fn new(channel: ChannelPtr, p2p: P2pPtr) -> Arc<Self> {
-        let settings = p2p.settings();
-
-        Arc::new(Self {
-            channel: channel.clone(),
-            settings,
-            jobsman: ProtocolJobsManager::new("ProtocolPing", channel),
-        })
-    }
-
-    pub async fn new2(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
+    pub async fn new(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
         let settings = p2p.settings();
 
         Arc::new(Self {

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

@@ -21,11 +21,7 @@ pub struct ProtocolSeed {
 
 impl ProtocolSeed {
     /// Create a new seed protocol.
-    pub fn new(channel: ChannelPtr, hosts: HostsPtr, settings: SettingsPtr) -> Arc<Self> {
-        Arc::new(Self { channel, hosts, settings })
-    }
-
-    pub async fn new2(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
+    pub async fn new(channel: ChannelPtr, p2p: P2pPtr) -> ProtocolBasePtr {
         let hosts = p2p.hosts();
         let settings = p2p.settings();