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

store: do not shuffle hosts on fetch_address()

Previously we were shuffling hosts that we select to avoid trying to
connect to them in a deterministic order. However, this contradicts the
protocol of ordering hostlists by last_seen.

Instead, we should try to connect to addresses stored at the top of the
hostlists first, as they are most likely to be active.

The problem of multiple slots competing for the same peer should be
solved by the various locking checks in check_address_with_lock().
lunar-mining 2 лет назад
Родитель
Сommit
2674cfd32e
1 измененных файлов с 0 добавлено и 12 удалено
  1. 0 12
      src/net/hosts/store.rs

+ 0 - 12
src/net/hosts/store.rs

@@ -125,10 +125,6 @@ impl Hosts {
             hosts.push((addr, last_seen));
             hosts.push((addr, last_seen));
         }
         }
 
 
-        // Randomize hosts list. Do not try to connect in a deterministic order.
-        // This is healthier for multiple slots to not compete for the same addrs.
-        hosts.shuffle(&mut OsRng);
-
         hosts
         hosts
     }
     }
 
 
@@ -171,10 +167,6 @@ impl Hosts {
         trace!(target: "store::whitelist_fetch_address()",
         trace!(target: "store::whitelist_fetch_address()",
         "Grabbed hosts, length: {}", hosts.len());
         "Grabbed hosts, length: {}", hosts.len());
 
 
-        // Randomize hosts list. Do not try to connect in a deterministic order.
-        // This is healthier for multiple slots to not compete for the same addrs.
-        hosts.shuffle(&mut OsRng);
-
         hosts
         hosts
     }
     }
 
 
@@ -217,10 +209,6 @@ impl Hosts {
         trace!(target: "store::anchorlist_fetch_address()",
         trace!(target: "store::anchorlist_fetch_address()",
         "Grabbed hosts, length: {}", hosts.len());
         "Grabbed hosts, length: {}", hosts.len());
 
 
-        // Randomize hosts list. Do not try to connect in a deterministic order.
-        // This is healthier for multiple slots to not compete for the same addrs.
-        hosts.shuffle(&mut OsRng);
-
         hosts
         hosts
     }
     }