mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 09:37:55 +00:00
Make RocksDB optional in client-db (#2686)
This commit is contained in:
committed by
André Silva
parent
902c9d03f2
commit
3a0c52f2b1
@@ -38,8 +38,7 @@ use runtime_primitives::traits::{
|
||||
};
|
||||
use consensus_common::well_known_cache_keys;
|
||||
use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType};
|
||||
use crate::utils::{self, meta_keys, Meta, db_err, open_database,
|
||||
read_db, block_id_to_lookup_key, read_meta};
|
||||
use crate::utils::{self, meta_keys, Meta, db_err, read_db, block_id_to_lookup_key, read_meta};
|
||||
use crate::DatabaseSettings;
|
||||
use log::{trace, warn, debug};
|
||||
|
||||
@@ -72,8 +71,19 @@ impl<Block> LightStorage<Block>
|
||||
{
|
||||
/// Create new storage with given settings.
|
||||
pub fn new(config: DatabaseSettings) -> ClientResult<Self> {
|
||||
let db = open_database(&config, columns::META, "light")?;
|
||||
Self::new_inner(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "kvdb-rocksdb")]
|
||||
fn new_inner(config: DatabaseSettings) -> ClientResult<Self> {
|
||||
let db = crate::utils::open_database(&config, columns::META, "light")?;
|
||||
Self::from_kvdb(db as Arc<_>)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "kvdb-rocksdb"))]
|
||||
fn new_inner(_config: DatabaseSettings) -> ClientResult<Self> {
|
||||
log::warn!("Running without the RocksDB feature. The database will NOT be saved.");
|
||||
let db = Arc::new(kvdb_memorydb::create(crate::utils::NUM_COLUMNS));
|
||||
Self::from_kvdb(db as Arc<_>)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user