Updated upgrade commands to set new default validator (#413)
This commit is contained in:
committed by
GitHub
parent
9d9d530581
commit
e4c8a6b72b
@@ -26,7 +26,7 @@ pub mod persistence;
|
||||
pub const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
|
||||
// 'CLIENT'
|
||||
const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net";
|
||||
pub const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net";
|
||||
|
||||
// 'DEBUG'
|
||||
const DEFAULT_ACK_WAIT_MULTIPLIER: f64 = 1.5;
|
||||
@@ -176,7 +176,7 @@ impl<T: NymConfig> Config<T> {
|
||||
self.client.gateway_listener = gateway_listener.into();
|
||||
}
|
||||
|
||||
pub fn with_custom_validator<S: Into<String>>(&mut self, validator: S) {
|
||||
pub fn set_custom_validator<S: Into<String>>(&mut self, validator: S) {
|
||||
self.client.validator_rest_url = validator.into();
|
||||
}
|
||||
|
||||
@@ -335,8 +335,7 @@ pub struct Client<T> {
|
||||
id: String,
|
||||
|
||||
/// URL to the validator server for obtaining network topology.
|
||||
// before 0.9.0 this was the directory server
|
||||
#[serde(alias = "directory_server")]
|
||||
#[serde(default = "missing_string_value")]
|
||||
validator_rest_url: String,
|
||||
|
||||
/// Special mode of the system such that all messages are sent as soon as they are received
|
||||
|
||||
@@ -21,7 +21,7 @@ pub(crate) mod upgrade;
|
||||
|
||||
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config {
|
||||
if let Some(validator) = matches.value_of("validator") {
|
||||
config.get_base_mut().with_custom_validator(validator);
|
||||
config.get_base_mut().set_custom_validator(validator);
|
||||
}
|
||||
|
||||
if let Some(gateway_id) = matches.value_of("gateway") {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use crate::client::config::{Config, MISSING_VALUE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use client_core::config::DEFAULT_VALIDATOR_REST_ENDPOINT;
|
||||
use config::NymConfig;
|
||||
use std::fmt::Display;
|
||||
use std::process;
|
||||
@@ -79,12 +80,27 @@ fn pre_090_upgrade(from: &str, mut config: Config) -> Config {
|
||||
Version::new(0, 9, 0)
|
||||
};
|
||||
|
||||
if config.get_base().get_validator_rest_endpoint() != MISSING_VALUE {
|
||||
eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
print_start_upgrade(&from_version, &to_version);
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.set_custom_version(to_version.to_string().as_ref());
|
||||
|
||||
println!(
|
||||
"Setting validator REST endpoint to to {}",
|
||||
DEFAULT_VALIDATOR_REST_ENDPOINT
|
||||
);
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.set_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT);
|
||||
|
||||
config.save_to_file(None).unwrap_or_else(|err| {
|
||||
eprintln!("failed to overwrite config file! - {:?}", err);
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
|
||||
@@ -21,7 +21,7 @@ pub(crate) mod upgrade;
|
||||
|
||||
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config {
|
||||
if let Some(validator) = matches.value_of("validator") {
|
||||
config.get_base_mut().with_custom_validator(validator);
|
||||
config.get_base_mut().set_custom_validator(validator);
|
||||
}
|
||||
|
||||
if let Some(gateway_id) = matches.value_of("gateway") {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use crate::client::config::{Config, MISSING_VALUE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use client_core::config::DEFAULT_VALIDATOR_REST_ENDPOINT;
|
||||
use config::NymConfig;
|
||||
use std::fmt::Display;
|
||||
use std::process;
|
||||
@@ -79,12 +80,27 @@ fn pre_090_upgrade(from: &str, mut config: Config) -> Config {
|
||||
Version::new(0, 9, 0)
|
||||
};
|
||||
|
||||
if config.get_base().get_validator_rest_endpoint() != MISSING_VALUE {
|
||||
eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
print_start_upgrade(&from_version, &to_version);
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.set_custom_version(to_version.to_string().as_ref());
|
||||
|
||||
println!(
|
||||
"Setting validator REST endpoint to to {}",
|
||||
DEFAULT_VALIDATOR_REST_ENDPOINT
|
||||
);
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.set_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT);
|
||||
|
||||
config.save_to_file(None).unwrap_or_else(|err| {
|
||||
eprintln!("failed to overwrite config file! - {:?}", err);
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::config::DEFAULT_VALIDATOR_REST_ENDPOINT;
|
||||
use crate::config::{Config, MISSING_VALUE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use config::NymConfig;
|
||||
@@ -81,7 +82,20 @@ fn pre_090_upgrade(from: &str, config: Config) -> Config {
|
||||
|
||||
print_start_upgrade(&from_version, &to_version);
|
||||
|
||||
let upgraded_config = config.with_custom_version(to_version.to_string().as_ref());
|
||||
if config.get_validator_rest_endpoint() != MISSING_VALUE {
|
||||
eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
println!(
|
||||
"Setting validator REST endpoint to to {}",
|
||||
DEFAULT_VALIDATOR_REST_ENDPOINT
|
||||
);
|
||||
|
||||
let upgraded_config = config
|
||||
.with_custom_version(to_version.to_string().as_ref())
|
||||
.with_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT);
|
||||
|
||||
upgraded_config.save_to_file(None).unwrap_or_else(|err| {
|
||||
eprintln!("failed to overwrite config file! - {:?}", err);
|
||||
|
||||
@@ -32,7 +32,7 @@ pub(crate) const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
// 'GATEWAY'
|
||||
const DEFAULT_MIX_LISTENING_PORT: u16 = 1789;
|
||||
const DEFAULT_CLIENT_LISTENING_PORT: u16 = 9000;
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net";
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net";
|
||||
|
||||
// 'DEBUG'
|
||||
// where applicable, the below are defined in milliseconds
|
||||
@@ -494,7 +494,7 @@ pub struct Gateway {
|
||||
public_sphinx_key_file: PathBuf,
|
||||
|
||||
/// Validator server to which the node will be reporting their presence data.
|
||||
#[serde(alias = "presence_directory_server")]
|
||||
#[serde(default = "missing_string_value")]
|
||||
validator_rest_url: String,
|
||||
|
||||
/// nym_home_directory specifies absolute path to the home nym gateways directory.
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::config::{missing_string_value, Config, DEFAULT_METRICS_SERVER};
|
||||
use crate::config::{
|
||||
missing_string_value, Config, DEFAULT_METRICS_SERVER, DEFAULT_VALIDATOR_REST_ENDPOINT,
|
||||
};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use config::NymConfig;
|
||||
use crypto::asymmetric::identity;
|
||||
@@ -94,16 +96,27 @@ fn pre_090_upgrade(from: &str, config: Config) -> Config {
|
||||
}
|
||||
|
||||
if config.get_metrics_server() != missing_string_value::<String>() {
|
||||
eprintln!("existing config seems to have specified new metrics-server endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
eprintln!("existing config seems to have specified new metrics-server endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
if config.get_validator_rest_endpoint() != missing_string_value::<String>() {
|
||||
eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade.");
|
||||
print_failed_upgrade(&from_version, &to_version);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let mut upgraded_config = config
|
||||
.with_custom_version(to_version.to_string().as_ref())
|
||||
.with_custom_metrics_server(DEFAULT_METRICS_SERVER);
|
||||
.with_custom_metrics_server(DEFAULT_METRICS_SERVER)
|
||||
.with_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT);
|
||||
|
||||
println!("Setting metrics server to {}", DEFAULT_METRICS_SERVER);
|
||||
println!(
|
||||
"Setting validator REST endpoint to to {}",
|
||||
DEFAULT_VALIDATOR_REST_ENDPOINT
|
||||
);
|
||||
|
||||
println!("Generating new identity...");
|
||||
let identity_keys = identity::KeyPair::new();
|
||||
|
||||
@@ -31,7 +31,7 @@ pub(crate) const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
|
||||
// 'MIXNODE'
|
||||
const DEFAULT_LISTENING_PORT: u16 = 1789;
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net";
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net";
|
||||
pub(crate) const DEFAULT_METRICS_SERVER: &str = "https://metrics.nymtech.net";
|
||||
|
||||
// 'DEBUG'
|
||||
@@ -396,7 +396,7 @@ pub struct MixNode {
|
||||
public_sphinx_key_file: PathBuf,
|
||||
|
||||
/// Validator server to which the node will be reporting their presence data.
|
||||
#[serde(alias = "presence_directory_server")]
|
||||
#[serde(default = "missing_string_value")]
|
||||
validator_rest_url: String,
|
||||
|
||||
/// Metrics server to which the node will be reporting their metrics data.
|
||||
|
||||
Reference in New Issue
Block a user