wip
This commit is contained in:
@@ -19,6 +19,7 @@ pub(crate) struct NymApiTopologyProvider {
|
||||
|
||||
impl NymApiTopologyProvider {
|
||||
pub(crate) fn new(mut nym_api_urls: Vec<Url>, client_version: String) -> Self {
|
||||
println!("new");
|
||||
nym_api_urls.shuffle(&mut thread_rng());
|
||||
|
||||
NymApiTopologyProvider {
|
||||
@@ -32,6 +33,7 @@ impl NymApiTopologyProvider {
|
||||
}
|
||||
|
||||
fn use_next_nym_api(&mut self) {
|
||||
println!("using next nym api");
|
||||
if self.nym_api_urls.len() == 1 {
|
||||
warn!("There's only a single nym API available - it won't be possible to use a different one");
|
||||
return;
|
||||
@@ -61,6 +63,7 @@ impl NymApiTopologyProvider {
|
||||
}
|
||||
|
||||
async fn get_current_compatible_topology(&mut self) -> Option<NymTopology> {
|
||||
println!("getting current compatible topology");
|
||||
let mixnodes = match self.validator_client.get_cached_active_mixnodes().await {
|
||||
Err(err) => {
|
||||
error!("failed to get network mixnodes - {err}");
|
||||
@@ -74,7 +77,11 @@ impl NymApiTopologyProvider {
|
||||
error!("failed to get network gateways - {err}");
|
||||
return None;
|
||||
}
|
||||
Ok(gateways) => gateways,
|
||||
Ok(gateways) => {
|
||||
dbg!(&gateways);
|
||||
panic!();
|
||||
gateways
|
||||
}
|
||||
};
|
||||
|
||||
let topology = nym_topology_from_detailed(mixnodes, gateways)
|
||||
@@ -95,6 +102,7 @@ impl NymApiTopologyProvider {
|
||||
#[async_trait]
|
||||
impl TopologyProvider for NymApiTopologyProvider {
|
||||
async fn get_new_topology(&mut self) -> Option<NymTopology> {
|
||||
println!("get_new_topology");
|
||||
self.get_current_compatible_topology().await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,44 @@ pub async fn current_gateways<R: Rng>(
|
||||
log::trace!("Fetching list of gateways from: {nym_api}");
|
||||
|
||||
let gateways = client.get_cached_gateways().await?;
|
||||
dbg!(&gateways);
|
||||
let mut g = gateways[0].clone();
|
||||
g.gateway = Gateway {
|
||||
// pub host: String,
|
||||
// pub mix_port: u16,
|
||||
// pub clients_port: u16,
|
||||
// pub location: String,
|
||||
// pub sphinx_key: String,
|
||||
// pub identity_key: String,
|
||||
// pub version: String,
|
||||
|
||||
/*
|
||||
pub struct Gateway {
|
||||
/// Network address of this gateway, for example 1.1.1.1 or foo.gateway.com
|
||||
pub host: String,
|
||||
|
||||
/// Port used by this gateway for listening for mix packets.
|
||||
pub mix_port: u16,
|
||||
|
||||
/// Port used by this gateway for listening for client requests.
|
||||
pub clients_port: u16,
|
||||
|
||||
/// The physical, self-reported, location of this gateway.
|
||||
// this field should be deprecated in favour of externally hosted information, like the mixnodes'.
|
||||
pub location: String,
|
||||
|
||||
/// Base58-encoded x25519 public key used for sphinx key derivation.
|
||||
pub sphinx_key: SphinxKey,
|
||||
|
||||
/// Base58 encoded ed25519 EdDSA public key of the gateway used to derive shared keys with clients
|
||||
pub identity_key: IdentityKey,
|
||||
|
||||
/// The self-reported semver version of this gateway.
|
||||
pub version: String,
|
||||
}
|
||||
*/
|
||||
};
|
||||
let gateways = vec![g];
|
||||
let valid_gateways = gateways
|
||||
.into_iter()
|
||||
.filter_map(|gateway| gateway.try_into().ok())
|
||||
|
||||
Reference in New Issue
Block a user