From 02add8d416fdef0c59b4da8248f5d2dd38b479e3 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 31 Jan 2020 11:47:46 +0000 Subject: [PATCH] More config getters + extra comments --- nym-client/src/config/mod.rs | 54 ++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/nym-client/src/config/mod.rs b/nym-client/src/config/mod.rs index ad4f73a2b8..06b368c691 100644 --- a/nym-client/src/config/mod.rs +++ b/nym-client/src/config/mod.rs @@ -68,6 +68,7 @@ impl Config { Config::default().with_id(id) } + // builder methods pub fn with_id>(mut self, id: S) -> Self { let id = id.into(); if self.client.private_identity_key_file.as_os_str().is_empty() { @@ -107,6 +108,11 @@ impl Config { self } + // getters + pub fn get_config_file_save_location(&self) -> PathBuf { + self.config_directory().join(Self::config_file_name()) + } + pub fn get_private_identity_key_file(&self) -> PathBuf { self.client.private_identity_key_file.clone() } @@ -115,8 +121,49 @@ impl Config { self.client.public_identity_key_file.clone() } - pub fn get_config_file_save_location(&self) -> PathBuf { - self.config_directory().join(Self::config_file_name()) + pub fn get_directory_server(&self) -> String { + self.client.directory_server.clone() + } + + pub fn get_provider_id(&self) -> String { + self.client.provider_id.clone() + } + + pub fn get_provider_auth_token(&self) -> Option { + self.client.provider_authtoken.clone() + } + + pub fn get_socket_type(&self) -> SocketType { + self.socket.socket_type + } + + pub fn get_listening_port(&self) -> u16 { + self.socket.listening_port + } + + // Debug getters + pub fn get_average_packet_delay(&self) -> u64 { + self.debug.average_packet_delay + } + + pub fn get_loop_cover_traffic_average_delay(&self) -> u64 { + self.debug.loop_cover_traffic_average_delay + } + + pub fn get_fetch_message_delay(&self) -> u64 { + self.debug.fetch_message_delay + } + + pub fn get_message_sending_average_delay(&self) -> u64 { + self.debug.message_sending_average_delay + } + + pub fn get_rate_compliant_cover_messages_disabled(&self) -> bool { + self.debug.rate_compliant_cover_messages_disabled + } + + pub fn get_topology_refresh_rate(&self) -> u64 { + self.debug.topology_refresh_rate } } @@ -139,7 +186,7 @@ pub struct Client { /// If initially omitted, a random provider will be chosen from the available topology. provider_id: String, - /// A provider specific, optional, stringified authentication token used for + /// A provider specific, optional, base58 stringified authentication token used for /// communication with particular provider. provider_authtoken: Option, @@ -249,6 +296,7 @@ pub struct Debug { /// meaning it will always try to use whatever it obtained on startup. /// The provided value is interpreted as milliseconds. topology_refresh_rate: u64, + // topology resolution timeout } impl Default for Debug {