mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 15:37:56 +00:00
Make it possible to disable RocksDB completely (#11537)
* Make it possible to disable RocksDB completely * Make ParityDB non-optional * Address review comments
This commit is contained in:
@@ -238,6 +238,7 @@ impl Into<sc_service::config::RpcMethods> for RpcMethods {
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
pub enum Database {
|
||||
/// Facebooks RocksDB
|
||||
#[cfg(feature = "rocksdb")]
|
||||
RocksDb,
|
||||
/// ParityDb. <https://github.com/paritytech/parity-db/>
|
||||
ParityDb,
|
||||
@@ -252,12 +253,14 @@ impl std::str::FromStr for Database {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, String> {
|
||||
#[cfg(feature = "rocksdb")]
|
||||
if s.eq_ignore_ascii_case("rocksdb") {
|
||||
Ok(Self::RocksDb)
|
||||
} else if s.eq_ignore_ascii_case("paritydb-experimental") {
|
||||
Ok(Self::ParityDbDeprecated)
|
||||
return Ok(Self::RocksDb)
|
||||
}
|
||||
if s.eq_ignore_ascii_case("paritydb-experimental") {
|
||||
return Ok(Self::ParityDbDeprecated)
|
||||
} else if s.eq_ignore_ascii_case("paritydb") {
|
||||
Ok(Self::ParityDb)
|
||||
return Ok(Self::ParityDb)
|
||||
} else if s.eq_ignore_ascii_case("auto") {
|
||||
Ok(Self::Auto)
|
||||
} else {
|
||||
@@ -268,8 +271,14 @@ impl std::str::FromStr for Database {
|
||||
|
||||
impl Database {
|
||||
/// Returns all the variants of this enum to be shown in the cli.
|
||||
pub fn variants() -> &'static [&'static str] {
|
||||
&["rocksdb", "paritydb", "paritydb-experimental", "auto"]
|
||||
pub const fn variants() -> &'static [&'static str] {
|
||||
&[
|
||||
#[cfg(feature = "rocksdb")]
|
||||
"rocksdb",
|
||||
"paritydb",
|
||||
"paritydb-experimental",
|
||||
"auto",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -220,6 +220,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
let rocksdb_path = base_path.join("db").join(role_dir);
|
||||
let paritydb_path = base_path.join("paritydb").join(role_dir);
|
||||
Ok(match database {
|
||||
#[cfg(feature = "rocksdb")]
|
||||
Database::RocksDb => DatabaseSource::RocksDb { path: rocksdb_path, cache_size },
|
||||
Database::ParityDb => DatabaseSource::ParityDb { path: paritydb_path },
|
||||
Database::ParityDbDeprecated => {
|
||||
@@ -500,7 +501,16 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
let net_config_dir = config_dir.join(DEFAULT_NETWORK_CONFIG_PATH);
|
||||
let client_id = C::client_id();
|
||||
let database_cache_size = self.database_cache_size()?.unwrap_or(1024);
|
||||
let database = self.database()?.unwrap_or(Database::RocksDb);
|
||||
let database = self.database()?.unwrap_or(
|
||||
#[cfg(feature = "rocksdb")]
|
||||
{
|
||||
Database::RocksDb
|
||||
},
|
||||
#[cfg(not(feature = "rocksdb"))]
|
||||
{
|
||||
Database::ParityDb
|
||||
},
|
||||
);
|
||||
let node_key = self.node_key(&net_config_dir)?;
|
||||
let role = self.role(is_dev)?;
|
||||
let max_runtime_instances = self.max_runtime_instances()?.unwrap_or(8);
|
||||
|
||||
Reference in New Issue
Block a user