Skip to content

Commit

Permalink
feat(validator-node): allow network to be configured via cli (#4190)
Browse files Browse the repository at this point in the history
Description
---
Adds `--network` cli option

Motivation and Context
---
Network was hard coded to dibbler

How Has This Been Tested?
---
Manually
  • Loading branch information
sdbondi authored Jun 14, 2022
1 parent 16d6ba5 commit 6a4c1a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions applications/tari_validator_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) struct Cli {
impl Cli {
pub fn config_property_overrides(&self) -> Vec<(String, String)> {
let mut overrides = self.common.config_property_overrides();
overrides.push(("network".to_string(), self.network.clone()));
overrides.push(("validator_node.override_from".to_string(), self.network.clone()));
overrides.push(("p2p.seeds.override_from".to_string(), self.network.clone()));
overrides
Expand Down
8 changes: 2 additions & 6 deletions applications/tari_validator_node/src/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
use std::sync::Arc;

use tari_app_utilities::{identity_management, identity_management::load_from_json};
use tari_common::{
configuration::Network,
exit_codes::{ExitCode, ExitError},
};
use tari_common::exit_codes::{ExitCode, ExitError};
use tari_comms::{protocol::rpc::RpcServer, NodeIdentity, UnspawnedCommsNode};
use tari_comms_dht::Dht;
use tari_dan_core::services::{ConcreteAssetProcessor, MempoolServiceHandle};
Expand Down Expand Up @@ -58,8 +55,7 @@ pub async fn build_service_and_comms_stack(
.add_initializer(P2pInitializer::new(
p2p_config.clone(),
config.peer_seeds.clone(),
// TODO: configurable
Network::Dibbler,
config.network,
node_identity.clone(),
publisher,
))
Expand Down
9 changes: 8 additions & 1 deletion applications/tari_validator_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ use std::{

use config::Config;
use serde::{Deserialize, Serialize};
use tari_common::{configuration::CommonConfig, ConfigurationError, DefaultConfigLoader, SubConfigPath};
use tari_common::{
configuration::{CommonConfig, Network},
ConfigurationError,
DefaultConfigLoader,
SubConfigPath,
};
use tari_comms::multiaddr::Multiaddr;
use tari_p2p::{P2pConfig, PeerSeedsConfig};

Expand All @@ -36,6 +41,7 @@ pub struct ApplicationConfig {
pub common: CommonConfig,
pub validator_node: ValidatorNodeConfig,
pub peer_seeds: PeerSeedsConfig,
pub network: Network,
}

impl ApplicationConfig {
Expand All @@ -44,6 +50,7 @@ impl ApplicationConfig {
common: CommonConfig::load_from(cfg)?,
validator_node: ValidatorNodeConfig::load_from(cfg)?,
peer_seeds: PeerSeedsConfig::load_from(cfg)?,
network: cfg.get("network")?,
};
config.validator_node.set_base_path(config.common.base_path());
Ok(config)
Expand Down
1 change: 1 addition & 0 deletions applications/tari_validator_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn main() {

fn main_inner() -> Result<(), ExitError> {
let cli = Cli::parse();
println!("Starting validator node on network {}", cli.network);
let config_path = cli.common.config_path();
let cfg = load_configuration(config_path, true, &cli.config_property_overrides())?;

Expand Down

0 comments on commit 6a4c1a4

Please sign in to comment.