Skip to content

Commit

Permalink
Renaming validator-api to nym-api (#1863)
Browse files Browse the repository at this point in the history
* Renaming validator-api to nym-api

* nym-api: simplified crate name

* Added nym-api rename to changelog

* Changed some output messages

* Renamed validator-api-requests to nym-api requests

* Removing more references to validator-api-requests

* Additional lockfile name changes after full build

* Removing mistakenly added merge files

* ibid

* ibid

* Getting rid of ref to validator_api deep inside validator-client

* Fixing file storage paths

* Renaming struct function names referring to validator_api

* Simplifying struct init

* Fixed up all other instances of nym_api.

* Renaming validatorApi to nymApi in TypeScript client for consistency

v

* Found a few more Rust instances

* Changed examples in TypeScript SDK

* Found one more instance of the use of validator instead of nym apis

* Aliasing config key name for deserialization to preserve compatibility with old configs
  • Loading branch information
futurechimp committed Dec 14, 2022
1 parent 4ece8b7 commit f6a79ce
Show file tree
Hide file tree
Showing 165 changed files with 600 additions and 640 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -74,8 +74,8 @@ members = [
"mixnode",
"service-providers/network-requester",
"service-providers/network-statistics",
"validator-api",
"validator-api/validator-api-requests",
"nym-api",
"nym-api/nym-api-requests",
"tools/nym-cli",
"tools/ts-rs-cli"
]
Expand All @@ -87,7 +87,7 @@ default-members = [
"service-providers/network-requester",
"service-providers/network-statistics",
"mixnode",
"validator-api",
"nym-api",
"explorer-api",
]

Expand Down
14 changes: 7 additions & 7 deletions clients/client-core/src/client/base_client/mod.rs
Expand Up @@ -85,7 +85,7 @@ pub struct BaseClientBuilder<'a, B> {
gateway_config: &'a GatewayEndpointConfig,
debug_config: &'a DebugConfig,
disabled_credentials: bool,
validator_api_endpoints: Vec<Url>,
nym_api_endpoints: Vec<Url>,
reply_storage_backend: B,

bandwidth_controller: Option<BandwidthController>,
Expand All @@ -106,7 +106,7 @@ where
gateway_config: base_config.get_gateway_endpoint_config(),
debug_config: base_config.get_debug_config(),
disabled_credentials: base_config.get_disabled_credentials_mode(),
validator_api_endpoints: base_config.get_validator_api_endpoints(),
nym_api_endpoints: base_config.get_nym_api_endpoints(),
bandwidth_controller,
reply_storage_backend,
key_manager,
Expand All @@ -120,13 +120,13 @@ where
bandwidth_controller: Option<BandwidthController>,
reply_storage_backend: B,
disabled_credentials: bool,
validator_api_endpoints: Vec<Url>,
nym_api_endpoints: Vec<Url>,
) -> BaseClientBuilder<'a, B> {
BaseClientBuilder {
gateway_config,
debug_config,
disabled_credentials,
validator_api_endpoints,
nym_api_endpoints,
bandwidth_controller,
reply_storage_backend,
key_manager,
Expand Down Expand Up @@ -281,13 +281,13 @@ where
// future responsible for periodically polling directory server and updating
// the current global view of topology
async fn start_topology_refresher(
validator_api_urls: Vec<Url>,
nym_api_urls: Vec<Url>,
refresh_rate: Duration,
topology_accessor: TopologyAccessor,
shutdown: ShutdownListener,
) -> Result<(), ClientCoreError<B>> {
let topology_refresher_config = TopologyRefresherConfig::new(
validator_api_urls,
nym_api_urls,
refresh_rate,
env!("CARGO_PKG_VERSION").to_string(),
);
Expand Down Expand Up @@ -386,7 +386,7 @@ where
.await?;

Self::start_topology_refresher(
self.validator_api_endpoints.clone(),
self.nym_api_endpoints.clone(),
self.debug_config.topology_refresh_rate,
shared_topology_accessor.clone(),
shutdown.subscribe(),
Expand Down
32 changes: 13 additions & 19 deletions clients/client-core/src/client/topology_control.rs
Expand Up @@ -136,19 +136,15 @@ impl Default for TopologyAccessor {
}

pub struct TopologyRefresherConfig {
validator_api_urls: Vec<Url>,
nym_api_urls: Vec<Url>,
refresh_rate: Duration,
client_version: String,
}

impl TopologyRefresherConfig {
pub fn new(
validator_api_urls: Vec<Url>,
refresh_rate: Duration,
client_version: String,
) -> Self {
pub fn new(nym_api_urls: Vec<Url>, refresh_rate: Duration, client_version: String) -> Self {
TopologyRefresherConfig {
validator_api_urls,
nym_api_urls,
refresh_rate,
client_version,
}
Expand All @@ -159,7 +155,7 @@ pub struct TopologyRefresher {
validator_client: validator_client::client::ApiClient,
client_version: String,

validator_api_urls: Vec<Url>,
nym_api_urls: Vec<Url>,
topology_accessor: TopologyAccessor,
refresh_rate: Duration,

Expand All @@ -169,30 +165,28 @@ pub struct TopologyRefresher {

impl TopologyRefresher {
pub fn new(mut cfg: TopologyRefresherConfig, topology_accessor: TopologyAccessor) -> Self {
cfg.validator_api_urls.shuffle(&mut thread_rng());
cfg.nym_api_urls.shuffle(&mut thread_rng());

TopologyRefresher {
validator_client: validator_client::client::ApiClient::new(
cfg.validator_api_urls[0].clone(),
),
validator_client: validator_client::client::ApiClient::new(cfg.nym_api_urls[0].clone()),
client_version: cfg.client_version,
validator_api_urls: cfg.validator_api_urls,
nym_api_urls: cfg.nym_api_urls,
topology_accessor,
refresh_rate: cfg.refresh_rate,
currently_used_api: 0,
was_latest_valid: true,
}
}

fn use_next_validator_api(&mut self) {
if self.validator_api_urls.len() == 1 {
warn!("There's only a single validator API available - it won't be possible to use a different one");
fn use_next_nym_api(&mut self) {
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;
}

self.currently_used_api = (self.currently_used_api + 1) % self.validator_api_urls.len();
self.currently_used_api = (self.currently_used_api + 1) % self.nym_api_urls.len();
self.validator_client
.change_validator_api(self.validator_api_urls[self.currently_used_api].clone())
.change_nym_api(self.nym_api_urls[self.currently_used_api].clone())
}

/// Verifies whether nodes a reasonably distributed among all mix layers.
Expand Down Expand Up @@ -288,7 +282,7 @@ impl TopologyRefresher {
let new_topology = self.get_current_compatible_topology().await;

if new_topology.is_none() {
self.use_next_validator_api();
self.use_next_nym_api();
}

if new_topology.is_none() && self.was_latest_valid {
Expand Down
13 changes: 7 additions & 6 deletions clients/client-core/src/config/mod.rs
Expand Up @@ -160,8 +160,8 @@ impl<T> Config<T> {
self.client.validator_urls = validator_urls;
}

pub fn set_custom_validator_apis(&mut self, validator_api_urls: Vec<Url>) {
self.client.validator_api_urls = validator_api_urls;
pub fn set_custom_nym_apis(&mut self, nym_api_urls: Vec<Url>) {
self.client.nym_api_urls = nym_api_urls;
}

pub fn set_high_default_traffic_volume(&mut self) {
Expand Down Expand Up @@ -221,8 +221,8 @@ impl<T> Config<T> {
self.client.validator_urls.clone()
}

pub fn get_validator_api_endpoints(&self) -> Vec<Url> {
self.client.validator_api_urls.clone()
pub fn get_nym_api_endpoints(&self) -> Vec<Url> {
self.client.nym_api_urls.clone()
}

pub fn get_gateway_id(&self) -> String {
Expand Down Expand Up @@ -409,7 +409,8 @@ pub struct Client<T> {
validator_urls: Vec<Url>,

/// Addresses to APIs running on validator from which the client gets the view of the network.
validator_api_urls: Vec<Url>,
#[serde(alias = "validator_api_urls")]
nym_api_urls: Vec<Url>,

/// Path to file containing private identity key.
private_identity_key_file: PathBuf,
Expand Down Expand Up @@ -456,7 +457,7 @@ impl<T: NymConfig> Default for Client<T> {
id: "".to_string(),
disabled_credentials_mode: true,
validator_urls: vec![],
validator_api_urls: vec![],
nym_api_urls: vec![],
private_identity_key_file: Default::default(),
public_identity_key_file: Default::default(),
private_encryption_key_file: Default::default(),
Expand Down
4 changes: 2 additions & 2 deletions clients/client-core/src/error.rs
Expand Up @@ -30,8 +30,8 @@ pub enum ClientCoreError<B: ReplyStorageBackend> {
#[error("Failed to setup gateway")]
FailedToSetupGateway,

#[error("List of validator apis is empty")]
ListOfValidatorApisIsEmpty,
#[error("List of nym apis is empty")]
ListOfNymApisIsEmpty,

#[error("Could not load existing gateway configuration: {0}")]
CouldNotLoadExistingGatewayConfiguration(std::io::Error),
Expand Down
8 changes: 4 additions & 4 deletions clients/client-core/src/init/helpers.rs
Expand Up @@ -24,12 +24,12 @@ pub(super) async fn query_gateway_details<B>(
where
B: ReplyStorageBackend,
{
let validator_api = validator_servers
let nym_api = validator_servers
.choose(&mut thread_rng())
.ok_or(ClientCoreError::ListOfValidatorApisIsEmpty)?;
let validator_client = validator_client::client::ApiClient::new(validator_api.clone());
.ok_or(ClientCoreError::ListOfNymApisIsEmpty)?;
let validator_client = validator_client::client::ApiClient::new(nym_api.clone());

log::trace!("Fetching list of gateways from: {}", validator_api);
log::trace!("Fetching list of gateways from: {}", nym_api);
let gateways = validator_client.get_cached_gateways().await?;
let valid_gateways = gateways
.into_iter()
Expand Down
9 changes: 3 additions & 6 deletions clients/client-core/src/init/mod.rs
Expand Up @@ -96,7 +96,7 @@ where
{
println!("Configuring gateway");
let gateway =
query_gateway_details(config.get_validator_api_endpoints(), user_chosen_gateway_id).await?;
query_gateway_details(config.get_nym_api_endpoints(), user_chosen_gateway_id).await?;
log::debug!("Querying gateway gives: {}", gateway);

// Registering with gateway by setting up and writing shared keys to disk
Expand All @@ -120,11 +120,8 @@ where
T: NymConfig,
{
println!("Using gateway provided by user, keeping existing keys");
let gateway = query_gateway_details(
config.get_validator_api_endpoints(),
Some(user_chosen_gateway_id),
)
.await?;
let gateway =
query_gateway_details(config.get_nym_api_endpoints(), Some(user_chosen_gateway_id)).await?;
log::debug!("Querying gateway gives: {}", gateway);
Ok(gateway.into())
}
Expand Down
4 changes: 2 additions & 2 deletions clients/native/src/client/config/template.rs
Expand Up @@ -31,8 +31,8 @@ validator_urls = [
]
# Addresses to APIs running on validator from which the client gets the view of the network.
validator_api_urls = [
{{#each client.validator_api_urls }}
nym_api_urls = [
{{#each client.nym_api_urls }}
'{{this}}',
{{/each}}
]
Expand Down
2 changes: 1 addition & 1 deletion clients/native/src/client/mod.rs
Expand Up @@ -56,7 +56,7 @@ impl SocketClient {
.expect("No nymd validator endpoint provided");
let api_url = config
.get_base()
.get_validator_api_endpoints()
.get_nym_api_endpoints()
.pop()
.expect("No validator api endpoint provided");
// overwrite env configuration with config URLs
Expand Down

0 comments on commit f6a79ce

Please sign in to comment.