From b0bec0d879e05ca15a4fe1b89c2c34af57993e1e Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 15 Jan 2020 19:11:20 +0300 Subject: [PATCH] use default in-memory for commands that don't use keystore --- bin/node/cli/src/cli.rs | 1 - client/cli/src/lib.rs | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index 7a4321802cf36..4442bb1b0378d 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -139,7 +139,6 @@ pub fn run(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Re &cli_args.shared_params, &version, )?; - sc_cli::fill_import_params(&mut config, &cli_args.import_params, ServiceRoles::FULL)?; match ChainSpec::from(config.chain_spec.id()) { diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index fe47eb8497994..1e8d40cb0f8c6 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -401,7 +401,8 @@ impl<'a> ParseAndPrepareExport<'a> { E: ChainSpecExtension, Exit: IntoExit { - let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + fill_config_keystore_in_memory(&mut config)?; if let DatabaseConfig::Path { ref path, .. } = &config.database { info!("DB path: {}", path.display()); @@ -523,6 +524,7 @@ impl<'a> CheckBlock<'a> { { let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; fill_import_params(&mut config, &self.params.import_params, sc_service::Roles::FULL)?; + fill_config_keystore_in_memory(&mut config)?; let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] }; let block_id = match FromStr::from_str(input) { @@ -559,9 +561,10 @@ impl<'a> ParseAndPreparePurge<'a> { G: RuntimeGenesis, E: ChainSpecExtension, { - let config = create_config_with_db_path::<(), _, _, _>( + let mut config = create_config_with_db_path::<(), _, _, _>( spec_factory, &self.params.shared_params, self.version )?; + fill_config_keystore_in_memory(&mut config)?; let db_path = match config.database { DatabaseConfig::Path { path, .. } => path, _ => { @@ -623,9 +626,11 @@ impl<'a> ParseAndPrepareRevert<'a> { G: RuntimeGenesis, E: ChainSpecExtension, { - let config = create_config_with_db_path( + let mut config = create_config_with_db_path( spec_factory, &self.params.shared_params, self.version )?; + fill_config_keystore_in_memory(&mut config)?; + let blocks = self.params.num.parse()?; builder(config)?.revert_chain(blocks)?; Ok(()) @@ -749,6 +754,16 @@ fn input_keystore_password() -> Result { .map_err(|e| format!("{:?}", e)) } +/// Use in memory keystore config when it is not required at all. +fn fill_config_keystore_in_memory(config: &mut sc_service::Configuration) + -> Result<(), String> +{ + match &mut config.keystore { + cfg @ KeystoreConfig::None => { *cfg = KeystoreConfig::InMemory; Ok(()) }, + _ => Err("Keystore config specified when it should not be!".into()), + } +} + /// Fill the password field of the given config instance. fn fill_config_keystore_password_and_path( config: &mut sc_service::Configuration,