From b2021030cc0d967cd5e7d0abc35382df5f4465f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 18 Feb 2021 14:58:01 +0100 Subject: [PATCH] Make it clear in CLI that paritydb is experimental (#8152) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make it clear in CLI that paritydb is experimental Sadly this is a breaking change for the CLI. * Update client/cli/src/params/database_params.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> --- substrate/client/cli/src/arg_enums.rs | 35 ++++++++++++++----- .../client/cli/src/params/database_params.rs | 3 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index 2ebfa38925..eb033144d7 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -165,18 +165,35 @@ impl Into for RpcMethods { } } -arg_enum! { - /// Database backend - #[allow(missing_docs)] - #[derive(Debug, Clone, Copy)] - pub enum Database { - // Facebooks RocksDB - RocksDb, - // ParityDb. https://github.com/paritytech/parity-db/ - ParityDb, +/// Database backend +#[derive(Debug, Clone, Copy)] +pub enum Database { + /// Facebooks RocksDB + RocksDb, + /// ParityDb. https://github.com/paritytech/parity-db/ + ParityDb, +} + +impl std::str::FromStr for Database { + type Err = String; + + fn from_str(s: &str) -> Result { + if s.eq_ignore_ascii_case("rocksdb") { + Ok(Self::RocksDb) + } else if s.eq_ignore_ascii_case("paritydb-experimental") { + Ok(Self::ParityDb) + } else { + Err(format!("Unknwon variant `{}`, known variants: {:?}", s, Self::variants())) + } } } +impl Database { + /// Returns all the variants of this enum to be shown in the cli. + pub fn variants() -> &'static [&'static str] { + &["rocksdb", "paritydb-experimental"] + } +} arg_enum! { /// Whether off-chain workers are enabled. diff --git a/substrate/client/cli/src/params/database_params.rs b/substrate/client/cli/src/params/database_params.rs index 23d2adc07f..3d5aca10d5 100644 --- a/substrate/client/cli/src/params/database_params.rs +++ b/substrate/client/cli/src/params/database_params.rs @@ -29,6 +29,7 @@ pub struct DatabaseParams { alias = "db", value_name = "DB", case_insensitive = true, + possible_values = &Database::variants(), )] pub database: Option, @@ -38,7 +39,7 @@ pub struct DatabaseParams { /// Enable storage chain mode /// - /// This changes the storage format for blocks bodys. + /// This changes the storage format for blocks bodies. /// If this is enabled, each transaction is stored separately in the /// transaction database column and is only referenced by hash /// in the block body column.