Эх сурвалжийг харах

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

redundant.jpeg
draoi 2 жил өмнө
parent
commit
1251ad3b38

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

@@ -108,9 +108,22 @@ impl GreylistRefinery {
                         continue
                         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;
                     let mut greylist = hosts.greylist.write().await;
                     if !ping_node(url.clone(), self.p2p().clone()).await {
                     if !ping_node(url.clone(), self.p2p().clone()).await {
                         greylist.remove(position);
                         greylist.remove(position);
+
+                        // Remove connection from pending
+                        self.p2p().remove_pending(&url).await;
                         debug!(
                         debug!(
                             target: "net::refinery",
                             target: "net::refinery",
                             "Peer {} is non-responsive. Removed from greylist", url,
                             "Peer {} is non-responsive. Removed from greylist", url,
@@ -127,6 +140,9 @@ impl GreylistRefinery {
 
 
                     // Remove whitelisted peer from the greylist.
                     // Remove whitelisted peer from the greylist.
                     hosts.greylist_remove(url, position).await;
                     hosts.greylist_remove(url, position).await;
+
+                    // Remove connection from pending
+                    self.p2p().remove_pending(&url).await;
                 }
                 }
                 None => {
                 None => {
                     debug!(target: "net::refinery", "No matching greylist entries found. Cannot proceed with refinery");
                     debug!(target: "net::refinery", "No matching greylist entries found. Cannot proceed with refinery");