draoi 2 лет назад
Родитель
Сommit
79512e6dce
3 измененных файлов с 11 добавлено и 23 удалено
  1. 5 2
      src/net/hosts/refinery.rs
  2. 2 1
      src/net/session/mod.rs
  3. 4 20
      src/net/tests.rs

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

@@ -164,11 +164,12 @@ async fn ping_node_impl(addr: Url, p2p: P2pPtr) -> bool {
 
     debug!(target: "net::refinery::ping_node()", "Attempting to connect to {}", addr);
     match connector.connect(&addr).await {
-        Ok((_url, channel)) => {
-            debug!(target: "net::refinery::ping_node()", "Connected successfully!");
+        Ok((url, channel)) => {
+            debug!(target: "net::refinery::ping_node()", "Successfully created a channel with {}", url);
             // First initialize the version protocol and its Version, Verack subscribers.
             let proto_ver = ProtocolVersion::new(channel.clone(), p2p.settings()).await;
 
+            debug!(target: "net::refinery::ping_node()", "Performing handshake protocols with {}", url);
             // Then run the version exchange, store the channel and subscribe to a stop signal.
             let handshake_task = session_outbound.perform_handshake_protocols(
                 proto_ver,
@@ -176,6 +177,7 @@ async fn ping_node_impl(addr: Url, p2p: P2pPtr) -> bool {
                 p2p.executor(),
             );
 
+            debug!(target: "net::refinery::ping_node()", "Starting channel {}", url);
             channel.clone().start(p2p.executor());
 
             // Ensure the channel gets stopped by adding a timeout to the handshake. Otherwise if
@@ -183,6 +185,7 @@ async fn ping_node_impl(addr: Url, p2p: P2pPtr) -> bool {
             // zombie processes.
             let result = timeout(Duration::from_secs(5), handshake_task).await;
 
+            debug!(target: "net::refinery::ping_node()", "Stopping channel {}", url);
             channel.stop().await;
 
             match result {

+ 2 - 1
src/net/session/mod.rs

@@ -96,7 +96,8 @@ pub trait Session: Sync {
 
         // Perform the handshake protocol
         let protocol_version = ProtocolVersion::new(channel.clone(), p2p.settings().clone()).await;
-        debug!(target: "net::session::register_channel()", "register_channel {}", channel.clone().address());
+        debug!(target: "net::session::register_channel()",
+        "Performing handshake protocols {}", channel.clone().address());
         let handshake_task =
             self.perform_handshake_protocols(protocol_version, channel.clone(), executor.clone());
 

+ 4 - 20
src/net/tests.rs

@@ -66,8 +66,8 @@ fn p2p_test() {
     // We check this error so we can execute same file tests in parallel,
     // otherwise second one fails to init logger here.
     if simplelog::TermLogger::init(
-        simplelog::LevelFilter::Info,
-        //simplelog::LevelFilter::Debug,
+        //simplelog::LevelFilter::Info,
+        simplelog::LevelFilter::Debug,
         //simplelog::LevelFilter::Trace,
         cfg.build(),
         simplelog::TerminalMode::Mixed,
@@ -155,26 +155,10 @@ async fn hostlist_propagation(ex: Arc<Executor<'static>>) {
     info!("Waiting until all peers connect");
     sleep(10).await;
 
-    info!("Inspecting hostlists...");
     for p2p in p2p_instances.iter() {
         let hosts = p2p.hosts();
-
-        let greylist = hosts.greylist.read().await;
-        let whitelist = hosts.whitelist.read().await;
-        let anchorlist = hosts.anchorlist.read().await;
-
-        info!("Node {}", p2p.settings().node_id);
-        for (i, (url, last_seen)) in greylist.iter().enumerate() {
-            info!("Greylist entry {}: {}, {}", i, url, last_seen);
-        }
-
-        for (i, (url, last_seen)) in whitelist.iter().enumerate() {
-            info!("Whitelist entry {}: {}, {}", i, url, last_seen);
-        }
-
-        for (i, (url, last_seen)) in anchorlist.iter().enumerate() {
-            info!("Anchorlist entry {}: {}, {}", i, url, last_seen);
-        }
+        // We should have some greylist entries at this point.
+        assert!(!hosts.is_empty_greylist().await);
     }
 
     // Stop the P2P network