Merge pull request #4247 from nymtech/fix/test-route-construction
Only use good nodes for test route construction
This commit is contained in:
@@ -146,7 +146,7 @@ impl PacketPreparer {
|
||||
let initialisation_backoff = Duration::from_secs(30);
|
||||
loop {
|
||||
let gateways = self.validator_cache.gateways_all().await;
|
||||
let mixnodes = self.validator_cache.mixnodes_basic().await;
|
||||
let mixnodes = self.validator_cache.mixnodes_all_basic().await;
|
||||
|
||||
if gateways.len() < minimum_full_routes {
|
||||
self.topology_wait_backoff(initialisation_backoff).await;
|
||||
@@ -179,12 +179,21 @@ impl PacketPreparer {
|
||||
async fn all_mixnodes_and_gateways(&self) -> (Vec<MixNodeBond>, Vec<GatewayBond>) {
|
||||
info!("Obtaining network topology...");
|
||||
|
||||
let mixnodes = self.validator_cache.mixnodes_basic().await;
|
||||
let mixnodes = self.validator_cache.mixnodes_all_basic().await;
|
||||
let gateways = self.validator_cache.gateways_all().await;
|
||||
|
||||
(mixnodes, gateways)
|
||||
}
|
||||
|
||||
async fn filtered_mixnodes_and_gateways(&self) -> (Vec<MixNodeBond>, Vec<GatewayBond>) {
|
||||
info!("Obtaining network topology...");
|
||||
|
||||
let mixnodes = self.validator_cache.mixnodes_filtered_basic().await;
|
||||
let gateways = self.validator_cache.gateways_filtered().await;
|
||||
|
||||
(mixnodes, gateways)
|
||||
}
|
||||
|
||||
pub(crate) fn try_parse_mix_bond(&self, mix: &MixNodeBond) -> Result<mix::Node, String> {
|
||||
let identity = mix.mix_node.identity_key.clone();
|
||||
mix.try_into().map_err(|_| identity)
|
||||
@@ -208,7 +217,7 @@ impl PacketPreparer {
|
||||
n: usize,
|
||||
blacklist: &mut HashSet<String>,
|
||||
) -> Option<Vec<TestRoute>> {
|
||||
let (mixnodes, gateways) = self.all_mixnodes_and_gateways().await;
|
||||
let (mixnodes, gateways) = self.filtered_mixnodes_and_gateways().await;
|
||||
// separate mixes into layers for easier selection
|
||||
let mut layered_mixes = HashMap::new();
|
||||
for mix in mixnodes {
|
||||
|
||||
+14
-13
@@ -182,19 +182,20 @@ impl NymContractCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn mixnodes_basic(&self) -> Vec<MixNodeBond> {
|
||||
match time::timeout(Duration::from_millis(100), self.inner.read()).await {
|
||||
Ok(cache) => cache
|
||||
.mixnodes
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(|bond| bond.bond_information)
|
||||
.collect(),
|
||||
Err(err) => {
|
||||
error!("{err}");
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
pub async fn mixnodes_filtered_basic(&self) -> Vec<MixNodeBond> {
|
||||
self.mixnodes_filtered()
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|bond| bond.bond_information)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub async fn mixnodes_all_basic(&self) -> Vec<MixNodeBond> {
|
||||
self.mixnodes_all()
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|bond| bond.bond_information)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub async fn gateways_filtered(&self) -> Vec<GatewayBond> {
|
||||
|
||||
@@ -119,7 +119,7 @@ impl StorageManager {
|
||||
r#"
|
||||
SELECT
|
||||
d.identity as "identity: String",
|
||||
AVG(reliability) as "value: f32"
|
||||
CASE WHEN count(*) > 3 THEN AVG(reliability) ELSE 100 END as "value: f32"
|
||||
FROM
|
||||
gateway_details d
|
||||
JOIN
|
||||
|
||||
Reference in New Issue
Block a user