Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions validator/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::commands::override_config;
use crate::config::Config;
// Commenting config out temporarily, we'll undoubtedly need it back soon.
// use crate::commands::override_config;
// use crate::config::Config;
// use config::NymConfig;
use crate::validator::Validator;
use clap::{App, Arg, ArgMatches};
use config::NymConfig;

pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
App::new("run")
Expand Down Expand Up @@ -54,12 +55,12 @@ pub fn execute(matches: &ArgMatches) {

println!("Starting validator {}...", id);

let mut config =
Config::load_from_file(matches.value_of("config").map(|path| path.into()), Some(id))
.expect("Failed to load config file");
// let mut config =
// Config::load_from_file(matches.value_of("config").map(|path| path.into()), Some(id))
// .expect("Failed to load config file");

config = override_config(config, matches);
// config = override_config(config, matches);

let validator = Validator::new(config);
let validator = Validator::new();
validator.start()
}
20 changes: 0 additions & 20 deletions validator/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ impl Config {
self.validator.location.clone()
}

pub fn get_mix_mining_directory_server(&self) -> String {
self.mix_mining.directory_server.clone()
}

// dead_code until validator actually sends the presence data
#[allow(dead_code)]
pub fn get_presence_directory_server(&self) -> String {
Expand All @@ -143,22 +139,6 @@ impl Config {
pub fn get_presence_sending_delay(&self) -> time::Duration {
time::Duration::from_millis(self.debug.presence_sending_delay)
}

pub fn get_mix_mining_run_delay(&self) -> time::Duration {
time::Duration::from_millis(self.mix_mining.run_delay)
}

pub fn get_mix_mining_resolution_timeout(&self) -> time::Duration {
time::Duration::from_millis(self.mix_mining.resolution_timeout)
}

pub fn get_mix_mining_number_of_test_packets(&self) -> u64 {
self.mix_mining.number_of_test_packets
}

pub fn get_healthcheck_connection_timeout(&self) -> time::Duration {
time::Duration::from_millis(self.mix_mining.connection_timeout)
}
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
Expand Down
58 changes: 0 additions & 58 deletions validator/src/services/mixmining/health_check_runner.rs

This file was deleted.

1 change: 0 additions & 1 deletion validator/src/services/mixmining/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use db::MixminingDb;
use models::*;

pub mod db;
pub mod health_check_runner;
pub mod models;
mod tests;

Expand Down
24 changes: 2 additions & 22 deletions validator/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::config::Config;
// use crate::config::Config;
use crate::network::rest;
use crate::network::tendermint;
use crate::services::mixmining;
use crate::services::mixmining::health_check_runner;
use crypto::identity::MixIdentityKeyPair;
use healthcheck::HealthChecker;
use tokio::runtime::Runtime;

pub struct Validator {
// when you re-introduce keys, check which ones you want:
// MixIdentityKeyPair (like 'nym-client' ) <- probably that one (after maybe renaming to just identity::KeyPair)
// encryption::KeyPair (like 'nym-mixnode' or 'sfw-provider')
health_check_runner: health_check_runner::HealthCheckRunner,
tendermint_abci: tendermint::Abci,
rest_api: rest::Api,
}

impl Validator {
pub fn new(config: Config) -> Self {
let dummy_healthcheck_keypair = MixIdentityKeyPair::new();
let hc = HealthChecker::new(
config.get_mix_mining_resolution_timeout(),
config.get_healthcheck_connection_timeout(),
config.get_mix_mining_number_of_test_packets() as usize,
dummy_healthcheck_keypair,
);

let health_check_runner = health_check_runner::HealthCheckRunner::new(
config.get_mix_mining_directory_server(),
config.get_mix_mining_run_delay(),
hc,
);

pub fn new() -> Self {
let mixmining_db = mixmining::db::MixminingDb::new();
let mixmining_service = mixmining::Service::new(mixmining_db);

let rest_api = rest::Api::new(mixmining_service);

Validator {
health_check_runner,
rest_api,

// perhaps you might want to pass &config to the constructor
Expand All @@ -64,7 +45,6 @@ impl Validator {
// TODO: Fix Tendermint startup here, see https://github.com/nymtech/nym/issues/147
pub fn start(self) {
let mut rt = Runtime::new().unwrap();
rt.spawn(self.health_check_runner.run());
rt.spawn(self.rest_api.run());
rt.spawn(self.tendermint_abci.run());

Expand Down