mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 03:18:01 +00:00
use default in-memory for commands that don't use keystore (#4634)
This commit is contained in:
committed by
Bastian Köcher
parent
28fada7daf
commit
058e98ef34
@@ -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<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>,
|
||||
|
||||
Reference in New Issue
Block a user