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

refinery: don't refine hosts that we are connected to/ trying to connect to

redundant.jpeg
draoi 2 лет назад
Родитель
Сommit
1251ad3b38
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      src/net/hosts/refinery.rs

+ 16 - 0
src/net/hosts/refinery.rs

@@ -108,9 +108,22 @@ impl GreylistRefinery {
                         continue
                     }
 
+                    // Don't refine nodes that we are already connected to.
+                    if self.p2p().exists(&url).await {
+                        continue
+                    }
+
+                    // Don't refine nodes that we are trying to connect to.
+                    if !self.p2p().add_pending(&url).await {
+                        continue
+                    }
+
                     let mut greylist = hosts.greylist.write().await;
                     if !ping_node(url.clone(), self.p2p().clone()).await {
                         greylist.remove(position);
+
+                        // Remove connection from pending
+                        self.p2p().remove_pending(&url).await;
                         debug!(
                             target: "net::refinery",
                             "Peer {} is non-responsive. Removed from greylist", url,
@@ -127,6 +140,9 @@ impl GreylistRefinery {
 
                     // Remove whitelisted peer from the greylist.
                     hosts.greylist_remove(url, position).await;
+
+                    // Remove connection from pending
+                    self.p2p().remove_pending(&url).await;
                 }
                 None => {
                     debug!(target: "net::refinery", "No matching greylist entries found. Cannot proceed with refinery");