Merge branch 'develop' of github.com:nymtech/nym into develop

This commit is contained in:
Jedrzej Stuczynski
2020-03-06 14:46:36 +00:00
6 changed files with 39 additions and 6 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
.arg(
Arg::with_name("host")
.long("host")
.help("The custom host on which the mixnode will be running")
.help("The host on which the mixnode will be running")
.takes_value(true)
.required(true),
)
@@ -38,13 +38,13 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
.arg(
Arg::with_name("announce-host")
.long("announce-host")
.help("The host that will be reported to the directory server")
.help("The custom host that will be reported to the directory server")
.takes_value(true),
)
.arg(
Arg::with_name("announce-port")
.long("announce-port")
.help("The port that will be reported to the directory server")
.help("The custom port that will be reported to the directory server")
.takes_value(true),
)
.arg(
+5
View File
@@ -5,8 +5,10 @@ pub mod init;
pub mod run;
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config {
let mut was_host_overridden = false;
if let Some(host) = matches.value_of("host") {
config = config.with_listening_host(host);
was_host_overridden = true;
}
if let Some(port) = matches.value_of("port").map(|port| port.parse::<u16>()) {
@@ -23,6 +25,9 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
if let Some(announce_host) = matches.value_of("announce-host") {
config = config.with_announce_host(announce_host);
} else if was_host_overridden {
// make sure our 'announce-host' always defaults to 'host'
config = config.announce_host_from_listening_host()
}
if let Some(announce_port) = matches
+5
View File
@@ -163,6 +163,11 @@ impl Config {
}
}
pub fn announce_host_from_listening_host(mut self) -> Self {
self.mixnode.announce_address = self.mixnode.listening_address.to_string();
self
}
pub fn with_announce_port(mut self, port: u16) -> Self {
let current_host: Vec<_> = self.mixnode.announce_address.split(':').collect();
debug_assert_eq!(current_host.len(), 2);
+5 -2
View File
@@ -33,8 +33,8 @@ pub(crate) type InputMessageSender = mpsc::UnboundedSender<InputMessage>;
pub(crate) type InputMessageReceiver = mpsc::UnboundedReceiver<InputMessage>;
pub struct NymClient {
runtime: Runtime,
config: Config,
runtime: Runtime,
identity_keypair: MixIdentityKeyPair,
// to be used by "send" function or socket, etc
@@ -201,7 +201,10 @@ impl NymClient {
TopologyRefresher::new(topology_refresher_config, topology_accessor);
// before returning, block entire runtime to refresh the current network view so that any
// components depending on topology would see a non-empty view
info!("Obtaining initial network topology...");
info!(
"Obtaining initial network topology from {}",
self.config.get_directory_server()
);
self.runtime.block_on(topology_refresher.refresh());
info!("Starting topology refresher...");
topology_refresher.start(self.runtime.handle());
+10 -1
View File
@@ -5,8 +5,10 @@ pub mod init;
pub mod run;
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config {
let mut was_mix_host_overridden = false;
if let Some(mix_host) = matches.value_of("mix-host") {
config = config.with_mix_listening_host(mix_host);
was_mix_host_overridden = true;
}
if let Some(mix_port) = matches.value_of("mix-port").map(|port| port.parse::<u16>()) {
@@ -16,9 +18,10 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
}
config = config.with_mix_listening_port(mix_port.unwrap());
}
let mut was_clients_host_overridden = false;
if let Some(clients_host) = matches.value_of("clients-host") {
config = config.with_clients_listening_host(clients_host);
was_clients_host_overridden = true;
}
if let Some(clients_port) = matches
@@ -34,6 +37,9 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
if let Some(mix_announce_host) = matches.value_of("mix-announce-host") {
config = config.with_mix_announce_host(mix_announce_host);
} else if was_mix_host_overridden {
// make sure our 'mix-announce-host' always defaults to 'mix-host'
config = config.mix_announce_host_from_listening_host()
}
if let Some(mix_announce_port) = matches
@@ -49,6 +55,9 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
if let Some(clients_announce_host) = matches.value_of("clients-announce-host") {
config = config.with_clients_announce_host(clients_announce_host);
} else if was_clients_host_overridden {
// make sure our 'clients-announce-host' always defaults to 'clients-host'
config = config.clients_announce_host_from_listening_host()
}
if let Some(clients_announce_port) = matches
+11
View File
@@ -171,6 +171,11 @@ impl Config {
}
}
pub fn mix_announce_host_from_listening_host(mut self) -> Self {
self.mixnet_endpoint.announce_address = self.mixnet_endpoint.listening_address.to_string();
self
}
pub fn with_mix_announce_port(mut self, port: u16) -> Self {
let current_host: Vec<_> = self.mixnet_endpoint.announce_address.split(':').collect();
debug_assert_eq!(current_host.len(), 2);
@@ -205,6 +210,12 @@ impl Config {
}
}
pub fn clients_announce_host_from_listening_host(mut self) -> Self {
self.clients_endpoint.announce_address =
self.clients_endpoint.listening_address.to_string();
self
}
pub fn with_clients_listening_port(mut self, port: u16) -> Self {
self.clients_endpoint.listening_address.set_port(port);
self