Fixed layer distribution skewness check (#1766)
This commit is contained in:
committed by
GitHub
parent
7e3bc2d6bb
commit
29c073d25c
@@ -186,13 +186,10 @@ impl TopologyRefresher {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `topology`: active topology constructed from validator api data
|
||||
/// * `mixnodes_count`: total number of active mixnodes
|
||||
fn check_layer_distribution(
|
||||
&self,
|
||||
active_topology: &NymTopology,
|
||||
mixnodes_count: usize,
|
||||
) -> bool {
|
||||
fn check_layer_distribution(&self, active_topology: &NymTopology) -> bool {
|
||||
let mixes = active_topology.mixes();
|
||||
let mixnodes_count = active_topology.num_mixnodes();
|
||||
|
||||
if active_topology.gateways().is_empty() {
|
||||
return false;
|
||||
}
|
||||
@@ -257,11 +254,10 @@ impl TopologyRefresher {
|
||||
Ok(gateways) => gateways,
|
||||
};
|
||||
|
||||
let mixnodes_count = mixnodes.len();
|
||||
let topology = nym_topology_from_detailed(mixnodes, gateways)
|
||||
.filter_system_version(&self.client_version);
|
||||
|
||||
if !self.check_layer_distribution(&topology, mixnodes_count) {
|
||||
if !self.check_layer_distribution(&topology) {
|
||||
warn!("The current filtered active topology has extremely skewed layer distribution. It cannot be used.");
|
||||
None
|
||||
} else {
|
||||
|
||||
@@ -84,6 +84,10 @@ impl NymTopology {
|
||||
&self.mixes
|
||||
}
|
||||
|
||||
pub fn num_mixnodes(&self) -> usize {
|
||||
self.mixes.values().flat_map(|m| m.iter()).count()
|
||||
}
|
||||
|
||||
pub fn mixes_as_vec(&self) -> Vec<mix::Node> {
|
||||
let mut mixes: Vec<mix::Node> = vec![];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user