Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
remove helper functions, use consts
  • Loading branch information
gnunicorn committed Nov 1, 2019
commit bd0f5de90cb61bc8b8c425e06afaf68e80693dd4
17 changes: 12 additions & 5 deletions core/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ use lazy_static::lazy_static;
use futures::Future;
use substrate_telemetry::TelemetryEndpoints;

/// default sub directory to store network config
const DEFAULT_NETWORK_CONFIG_PATH : &'static str = "network";
/// default sub directory to store database
const DEFAULT_DB_CONFIG_PATH : &'static str = "db";
/// default sub directory for the key store
const DEFAULT_KEYSTORE_CONFIG_PATH : &'static str = "keystore";

/// The maximum number of characters for a node name.
const NODE_NAME_MAX_LENGTH: usize = 32;

Expand Down Expand Up @@ -325,7 +332,7 @@ impl<'a> ParseAndPrepareBuildSpec<'a> {
let cfg = service::Configuration::<C,_,_>::default_with_spec_and_base_path(spec.clone(), Some(base_path));
let node_key = node_key_config(
self.params.node_key_params,
&Some(cfg.network_path().expect("We provided a base_path"))
&Some(cfg.in_chain_config_dir(DEFAULT_NETWORK_CONFIG_PATH).expect("We provided a base_path"))
)?;
let keys = node_key.into_keypair()?;
let peer_id = keys.public().into_peer_id();
Expand Down Expand Up @@ -682,10 +689,10 @@ where
)?
}

config.keystore_path = cli.keystore_path.or_else(|| config.in_chain_config_dir("keystore"));
config.keystore_path = cli.keystore_path.or_else(|| config.in_chain_config_dir(DEFAULT_KEYSTORE_CONFIG_PATH));

config.database = DatabaseConfig::Path {
path: config.in_chain_config_dir("db").expect("We provided a base_path."),
path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."),
cache_size: cli.database_cache_size,
};
config.state_cache_size = cli.state_cache_size;
Expand Down Expand Up @@ -752,7 +759,7 @@ where
let client_id = config.client_id();
fill_network_configuration(
cli.network_config,
config.network_path().expect("We provided a basepath"),
config.in_chain_config_dir(DEFAULT_NETWORK_CONFIG_PATH).expect("We provided a basepath"),
&mut config.network,
client_id,
is_dev,
Expand Down Expand Up @@ -818,7 +825,7 @@ where

let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path));
config.database = DatabaseConfig::Path {
path: config.in_chain_config_dir("db").expect("We provided a base_path."),
path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."),
cache_size: None,
};

Expand Down
5 changes: 0 additions & 5 deletions core/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ impl<C, G, E> Configuration<C, G, E> {
path
})
}

/// The basepath for the network file
pub fn network_path(&self) -> Option<PathBuf> {
self.in_chain_config_dir("network")
}
}

/// Returns platform info
Expand Down