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

store: don't remove from greylist or whitelist on anchorlist upgrade

because of the refinery running in the background, if we remove a peer
from the white or greylist on upgrade it can create an index error in
when seperate threads execute this code at the same time:

refinery:
    upgrades node to whitelist, removes from greylist

upgrade_host:
    upgrades node to anchorlist, removes from greylist

leaving a "safe" peer on the grey or whitelist is not a problem. the
only impact is that we risk selecting a peer from the whitelist that we
are already connected as an anchor, but p2p checks exist to protect
from this.

equally, if we remove from the greylist or whitelist on upgrade_host this can
happen:

upgrade_host:
    upgrades node to anchorlist, removes from greylist

protocol_addr:
    recv Addr
    do we have this node? no, add to greylist
    refinery: promotes to whitelist, etc

the above scenario makes removing the host in this case redundant.
lunar-mining 2 лет назад
Родитель
Сommit
818ceaec4d
1 измененных файлов с 2 добавлено и 23 удалено
  1. 2 23
      src/net/hosts/store.rs

+ 2 - 23
src/net/hosts/store.rs

@@ -259,30 +259,9 @@ impl Hosts {
         None
     }
 
-    /// Upgrade a connection to the anchorlist and remove it from the white or greylist.
-    /// Called after a connection has been successfully established in Outbound and Manual
-    /// sessions.
+    /// Upgrade a connection to the anchorlist. Called after a connection has been successfully
+    /// established in Outbound and Manual sessions.
     pub async fn upgrade_host(&self, addr: &Url) {
-        // Remove channel from whitelist
-        if self.whitelist_contains(addr).await {
-            let index = self
-                .get_whitelist_index_at_addr(addr.clone())
-                .await
-                .expect("Expected whitelist entry to exist");
-
-            self.whitelist_remove(addr, index).await;
-        }
-
-        // Remove channel from greylist
-        if self.greylist_contains(addr).await {
-            let index = self
-                .get_greylist_index_at_addr(addr.clone())
-                .await
-                .expect("Expected greylist entry to exist");
-            self.greylist_remove(addr, index).await;
-        }
-
-        // Add channel to anchorlist
         let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
         self.anchorlist_store_or_update(&[(addr.clone(), last_seen)]).await;
     }