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

net/hosts: rename load_*/get_* to fetch_*. We are doing an async get, so fetch more accurately conveys meaning here

x 3 лет назад
Родитель
Сommit
68d51f794a
3 измененных файлов с 6 добавлено и 6 удалено
  1. 3 3
      src/net/hosts.rs
  2. 1 1
      src/net/protocol/protocol_address.rs
  3. 2 2
      src/net/session/outbound_session.rs

+ 3 - 3
src/net/hosts.rs

@@ -206,12 +206,12 @@ impl Hosts {
     }
 
     /// Return all known hosts
-    pub async fn load_all(&self) -> Vec<Url> {
+    pub async fn fetch_all(&self) -> Vec<Url> {
         self.addrs.read().await.iter().cloned().collect()
     }
 
     /// Get up to n random hosts from the hosts set.
-    pub async fn get_n_random(&self, n: u32) -> Vec<Url> {
+    pub async fn fetch_n_random(&self, n: u32) -> Vec<Url> {
         let n = n as usize;
         let addrs = self.addrs.read().await;
         let urls = addrs.iter().choose_multiple(&mut OsRng, n.min(addrs.len()));
@@ -220,7 +220,7 @@ impl Hosts {
     }
 
     /// Get all peers that match the given transport schemes from the hosts set.
-    pub async fn load_with_schemes(&self, schemes: &[String]) -> Vec<Url> {
+    pub async fn fetch_with_schemes(&self, schemes: &[String]) -> Vec<Url> {
         let mut ret = vec![];
 
         for addr in self.addrs.read().await.iter() {

+ 1 - 1
src/net/protocol/protocol_address.rs

@@ -113,7 +113,7 @@ impl ProtocolAddress {
                 "Received GetAddrs({}) message from {}", get_addrs_msg.max, self.channel.address(),
             );
 
-            let addrs = self.hosts.get_n_random(get_addrs_msg.max).await;
+            let addrs = self.hosts.fetch_n_random(get_addrs_msg.max).await;
             debug!(
                 target: "net::protocol_address::handle_receive_get_addrs()",
                 "Sending {} addresses to {}", addrs.len(), self.channel.address(),

+ 2 - 2
src/net/session/outbound_session.rs

@@ -293,7 +293,7 @@ impl OutboundSession {
             macro_rules! mix_transport {
                 ($a:expr, $b:expr) => {
                     if transports.contains(&$a.to_string()) && transport_mixing {
-                        let mut a_to_b = p2p.hosts().load_with_schemes(&[$b.to_string()]).await;
+                        let mut a_to_b = p2p.hosts().fetch_with_schemes(&[$b.to_string()]).await;
                         for addr in a_to_b.iter_mut() {
                             addr.set_scheme($a).unwrap();
                             hosts.insert(addr.clone());
@@ -307,7 +307,7 @@ impl OutboundSession {
             mix_transport!("nym+tls", "tcp+tls");
 
             // And now the actual requested transports
-            for addr in p2p.hosts().load_with_schemes(transports).await {
+            for addr in p2p.hosts().fetch_with_schemes(transports).await {
                 hosts.insert(addr);
             }