Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use default in-memory keystore for commands that don't use keystore #4634

Merged
merged 1 commit into from
Jan 16, 2020
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
1 change: 0 additions & 1 deletion bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ pub fn run<I, T, E>(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()) {
Expand Down
21 changes: 18 additions & 3 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
_ => {
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -749,6 +754,16 @@ fn input_keystore_password() -> Result<String, String> {
.map_err(|e| format!("{:?}", e))
}

/// Use in memory keystore config when it is not required at all.
fn fill_config_keystore_in_memory<C, G, E>(config: &mut sc_service::Configuration<C, G, E>)
-> 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<C, G, E>(
config: &mut sc_service::Configuration<C, G, E>,
Expand Down