From f9c7ae8fddbeac4dfce760b260c705ff3ac9d118 Mon Sep 17 00:00:00 2001 From: Aria Date: Sat, 4 Nov 2023 20:06:12 +0000 Subject: undo last commit This reverts commit 4b6e257263f7bb6eaebb9be672f88bda85c77586. --- broadcast/src/topology.rs | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'broadcast/src/topology.rs') diff --git a/broadcast/src/topology.rs b/broadcast/src/topology.rs index bb10466..5e16666 100644 --- a/broadcast/src/topology.rs +++ b/broadcast/src/topology.rs @@ -14,40 +14,16 @@ impl Topology { for node_id in node_ids.iter() { top.insert(node_id.clone(), node_ids.iter().cloned().collect()); } - Self::filter_desc(&mut top); Topology(RwLock::new(top)) } /// Replace the current topology with a new one. - pub async fn replace(&self, mut new: TopologyDesc) { - Self::filter_desc(&mut new); + pub async fn replace(&self, new: TopologyDesc) { *self.0.write().await = new; } - fn filter_desc(desc: &mut TopologyDesc) { - for (node_id, neighbours) in desc.iter_mut() { - neighbours.remove(node_id); - } - } - - /// Get the next targets from the given topology, for a message - /// which has travelled across the given path and is now at node_id. - pub async fn targets(&self, node_id: &String, last_node_id: &String) -> HashSet { - // Ensure we don't keep holding the read lock - let topology = self.0.read().await; - - // Get all nodes the last node sent it to - let visited = topology.get(last_node_id); - - let neighbours = topology.get(node_id).unwrap(); - match visited { - Some(visited) => neighbours - .difference(&visited) - .cloned() - .filter(|n| n != node_id) - .collect(), - None => neighbours.clone(), - } + pub async fn all_targets(&self, node_id: &NodeId) -> HashSet { + self.0.read().await.get(node_id).unwrap().clone() } } -- cgit v1.2.3