allow emtpy topology to be served

This commit is contained in:
Simon Wicky
2023-08-04 15:08:01 +02:00
parent abaa64a54b
commit 4bfe533b51
2 changed files with 17 additions and 3 deletions
@@ -102,14 +102,18 @@ impl NymApiTopologyProvider {
let topology = nym_topology_from_detailed(mixnodes, gateways)
.with_epoch(current_epoch)
.with_all_mixes(all_mixes)
.with_all_gateways(all_gateways)
.with_all_mixes(all_mixes.clone())
.with_all_gateways(all_gateways.clone())
.filter_system_version(&self.client_version);
if let Err(err) = self.check_layer_distribution(&topology) {
warn!("The current filtered active topology has extremely skewed layer distribution. It cannot be used: {err}");
self.use_next_nym_api();
None
let empty_topology = NymTopology::empty()
.with_epoch(current_epoch)
.with_all_mixes(all_mixes)
.with_all_gateways(all_gateways);
Some(empty_topology)
} else {
Some(topology)
}
+10
View File
@@ -88,6 +88,16 @@ impl NymTopology {
}
}
pub fn empty() -> Self {
NymTopology {
mixes: BTreeMap::new(),
gateways: Vec::new(),
epoch: 0,
all_mixes: Vec::new(),
all_gateways: Vec::new(),
}
}
pub fn with_epoch(mut self, epoch: EpochId) -> Self {
self.epoch = epoch;
self