diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 99fb5571b6..e0d9443d62 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -200,13 +200,14 @@ pub fn run(args: I, worker: W) -> error::Result<()> where } let base_path = base_path(&matches); + config.keystore_path = matches.value_of("keystore") .map(|x| Path::new(x).to_owned()) - .unwrap_or_else(|| keystore_path(&base_path)) + .unwrap_or_else(|| keystore_path(&base_path, config.chain_spec.id())) .to_string_lossy() .into(); - config.database_path = db_path(&base_path).to_string_lossy().into(); + config.database_path = db_path(&base_path, config.chain_spec.id()).to_string_lossy().into(); config.pruning = match matches.value_of("pruning") { Some("archive") => PruningMode::ArchiveAll, @@ -250,7 +251,7 @@ pub fn run(args: I, worker: W) -> error::Result<()> where config.network.boot_nodes.extend(matches .values_of("bootnodes") .map_or(Default::default(), |v| v.map(|n| n.to_owned()).collect::>())); - config.network.config_path = Some(network_path(&base_path).to_string_lossy().into()); + config.network.config_path = Some(network_path(&base_path, config.chain_spec.id()).to_string_lossy().into()); config.network.net_config_path = config.network.config_path.clone(); let port = match matches.value_of("port") { @@ -326,7 +327,7 @@ fn export_blocks(matches: &clap::ArgMatches, exit: E) -> error::Result<()> let base_path = base_path(matches); let (spec, _) = load_spec(&matches)?; let mut config = service::Configuration::default_with_spec(spec); - config.database_path = db_path(&base_path).to_string_lossy().into(); + config.database_path = db_path(&base_path, config.chain_spec.id()).to_string_lossy().into(); info!("DB path: {}", config.database_path); let client = service::new_client(config)?; let (exit_send, exit_recv) = std::sync::mpsc::channel(); @@ -391,7 +392,7 @@ fn import_blocks(matches: &clap::ArgMatches, exit: E) -> error::Result<()> let (spec, _) = load_spec(&matches)?; let base_path = base_path(matches); let mut config = service::Configuration::default_with_spec(spec); - config.database_path = db_path(&base_path).to_string_lossy().into(); + config.database_path = db_path(&base_path, config.chain_spec.id()).to_string_lossy().into(); let client = service::new_client(config)?; let (exit_send, exit_recv) = std::sync::mpsc::channel(); @@ -499,20 +500,26 @@ fn parse_address(default: &str, port_param: &str, matches: &clap::ArgMatches) -> Ok(address) } -fn keystore_path(base_path: &Path) -> PathBuf { +fn keystore_path(base_path: &Path, chain_id: &str) -> PathBuf { let mut path = base_path.to_owned(); + path.push("chains"); + path.push(chain_id); path.push("keystore"); path } -fn db_path(base_path: &Path) -> PathBuf { +fn db_path(base_path: &Path, chain_id: &str) -> PathBuf { let mut path = base_path.to_owned(); + path.push("chains"); + path.push(chain_id); path.push("db"); path } -fn network_path(base_path: &Path) -> PathBuf { +fn network_path(base_path: &Path, chain_id: &str) -> PathBuf { let mut path = base_path.to_owned(); + path.push("chains"); + path.push(chain_id); path.push("network"); path } diff --git a/polkadot/service/res/poc-1.json b/polkadot/service/res/poc-1.json index 8828374714..e1954ee854 100644 --- a/polkadot/service/res/poc-1.json +++ b/polkadot/service/res/poc-1.json @@ -1,5 +1,6 @@ { "name": "PoC-1 Testnet", +"id": "poc-1-testnet", "genesis": {"raw": { "0x9768f3cbdd14c1a63474dfbdbe052f42": "0x80f4030000000000", "0x3b700687fecdff5ec1c4a5b714521eb6": "0x0000000000000000", diff --git a/polkadot/service/src/chain_spec.rs b/polkadot/service/src/chain_spec.rs index b03a6a6005..68ac4d5660 100644 --- a/polkadot/service/src/chain_spec.rs +++ b/polkadot/service/src/chain_spec.rs @@ -94,7 +94,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig { /// Staging testnet config. pub fn staging_testnet_config() -> ChainSpec { let boot_nodes = vec![]; - ChainSpec::from_genesis("Staging Testnet", staging_testnet_config_genesis, boot_nodes) + ChainSpec::from_genesis("Staging Testnet", "staging_testnet", staging_testnet_config_genesis, boot_nodes) } fn testnet_genesis(initial_authorities: Vec) -> GenesisConfig { @@ -169,7 +169,7 @@ fn development_config_genesis() -> GenesisConfig { /// Development config (single validator Alice) pub fn development_config() -> ChainSpec { - ChainSpec::from_genesis("Development", development_config_genesis, vec![]) + ChainSpec::from_genesis("Development", "development", development_config_genesis, vec![]) } fn local_testnet_genesis() -> GenesisConfig { @@ -181,5 +181,5 @@ fn local_testnet_genesis() -> GenesisConfig { /// Local testnet config (multivalidator Alice + Bob) pub fn local_testnet_config() -> ChainSpec { - ChainSpec::from_genesis("Local Testnet", local_testnet_genesis, vec![]) + ChainSpec::from_genesis("Local Testnet", "local_testnet", local_testnet_genesis, vec![]) }