diff --git a/src/model.rs b/src/model.rs index 149c936..d402e33 100644 --- a/src/model.rs +++ b/src/model.rs @@ -11,7 +11,7 @@ pub struct MapCollector { pub fn create_map_collector() -> (MapCollector, MapHandle) { let (nodes_tx, nodes_rx) = mpsc::unbounded_channel(); let (vertices_tx, vertices_rx) = mpsc::unbounded_channel(); - let scanned = Arc::new(RwLock::new(HashSet::new())); + let scanned = Arc::new(RwLock::new(Vec::new())); ( MapCollector { nodes_rx, vertices_rx }, MapHandle { nodes_tx, vertices_tx, scanned }, @@ -55,7 +55,7 @@ impl MapCollector { let to = { if let Some(node) = nodes_map.get_mut(&vertex.to) { - node.value += 5; + node.value += 10; node.id } else { tracing::warn!("vertex to nonexisting node {}", vertex.to); @@ -76,16 +76,20 @@ impl MapCollector { #[derive(Clone)] pub struct MapHandle { - scanned: Arc>>, + scanned: Arc>>, nodes_tx: mpsc::UnboundedSender, vertices_tx: mpsc::UnboundedSender, } impl MapHandle { pub async fn already_scanned(&self, domain: &str) -> bool { - let present = self.scanned.read().await.contains(domain); - if !present { self.scanned.write().await.insert(domain.to_string()); } - present + for scanned_domain in self.scanned.read().await.iter() { + if scanned_domain.ends_with(domain) || domain.ends_with(scanned_domain) { + return true; + } + } + self.scanned.write().await.push(domain.to_string()); + false } pub fn add_node(&self, domain: String, name: String) {