Procházet zdrojové kódy

hosts: make peers() reject both seed and refine session channels

draoi před 2 roky
rodič
revize
a316bcc84e
1 změnil soubory, kde provedl 9 přidání a 3 odebrání
  1. 9 3
      src/net/hosts.rs

+ 9 - 3
src/net/hosts.rs

@@ -32,7 +32,11 @@ use rand::{prelude::IteratorRandom, rngs::OsRng, Rng};
 use smol::lock::RwLock as AsyncRwLock;
 use smol::lock::RwLock as AsyncRwLock;
 use url::Url;
 use url::Url;
 
 
-use super::{session::SESSION_SEED, settings::Settings, ChannelPtr};
+use super::{
+    session::{SESSION_REFINE, SESSION_SEED},
+    settings::Settings,
+    ChannelPtr,
+};
 use crate::{
 use crate::{
     system::{Publisher, PublisherPtr, Subscription},
     system::{Publisher, PublisherPtr, Subscription},
     util::{
     util::{
@@ -986,9 +990,11 @@ impl Hosts {
 
 
         for (_, state) in registry.iter() {
         for (_, state) in registry.iter() {
             if let HostState::Connected(c) = state {
             if let HostState::Connected(c) = state {
-                if c.session_type_id() & SESSION_SEED == 0 {
-                    channels.push(c.clone());
+                // Skip this channel is it's a seed or refine session.
+                if c.session_type_id() & (SESSION_SEED | SESSION_REFINE) != 0 {
+                    continue
                 }
                 }
+                channels.push(c.clone());
             }
             }
         }
         }
         channels
         channels