diff --git a/common/topology/src/lib.rs b/common/topology/src/lib.rs index 486a4340bc..f960f559e3 100644 --- a/common/topology/src/lib.rs +++ b/common/topology/src/lib.rs @@ -100,13 +100,9 @@ pub trait NymTopology: Sized { expected_provider_version: &str, expected_coco_version: &str, ) -> Self { - let unversioned_mixnodes = self.mix_nodes(); - // let f = Filter::new(unversioned_mixnodes) - // unversioned_mixnodes - - let mixes = self.filter::(self.mix_nodes(), expected_mix_version); - let providers = self.filter::(self.providers(), expected_provider_version); - let cocos = self.filter::(self.coco_nodes(), expected_coco_version); + let mixes = Filter::new(self.mix_nodes()).run(expected_mix_version); + let providers = Filter::new(self.providers()).run(expected_provider_version); + let cocos = Filter::new(self.coco_nodes()).run(expected_coco_version); Self::new_from_nodes(mixes, providers, cocos) } @@ -132,18 +128,16 @@ pub trait Versioned: Clone + Sized { } pub struct Filter { - _phantom_data: PhantomData, + nodes: Vec, } impl Filter { - fn new() -> Self { - Self { - _phantom_data: PhantomData, - } + fn new(nodes: Vec) -> Self { + Self { nodes } } - fn run(&self, nodes: Vec, expected_version: &str) -> Vec { - nodes + fn run(&self, expected_version: &str) -> Vec { + self.nodes .iter() .filter(|node| version_checker::is_compatible(&node.get_version(), expected_version)) .cloned() @@ -151,20 +145,6 @@ impl Filter { } } -// impl VersionFilter { -// fn new() -> Self { -// Self {} -// } - -// fn run(&self, nodes: Vec, expected_version: &str) -> Vec { -// nodes -// .iter() -// .filter(|node| version_checker::is_compatible(&node.get_version(), expected_version)) -// .cloned() -// .collect() -// } -// } - #[derive(Debug)] pub enum NymTopologyError { InvalidMixLayerError,