Make all features explicit (#6267)

* make all features explicit

* Change to -feature suffix to with- prefix

* Add newline at the end of the Cargo.toml file

* Remove rhd feature

* Remove some features from Cargo.toml

* Remove test-helpers feature in tx pool

* Return db_open_error("with-"..

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Rename subdb feature to with-subdb

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove 'strict' feature and cfg_attr

* Check for with-subdb feature instead of subdb

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
pscott
2020-06-08 15:43:00 +02:00
committed by GitHub
parent d884848625
commit 05ed129673
7 changed files with 21 additions and 19 deletions
+3
View File
@@ -47,3 +47,6 @@ tempfile = "3"
[features]
default = []
test-helpers = []
with-kvdb-rocksdb = ["kvdb-rocksdb"]
with-parity-db = ["parity-db"]
with-subdb = []
+5 -5
View File
@@ -31,20 +31,20 @@
pub mod light;
pub mod offchain;
#[cfg(any(feature = "kvdb-rocksdb", test))]
#[cfg(any(feature = "with-kvdb-rocksdb", test))]
pub mod bench;
mod children;
mod cache;
mod changes_tries_storage;
mod storage_cache;
#[cfg(any(feature = "kvdb-rocksdb", test))]
#[cfg(any(feature = "with-kvdb-rocksdb", test))]
mod upgrade;
mod utils;
mod stats;
#[cfg(feature = "parity-db")]
#[cfg(feature = "with-parity-db")]
mod parity_db;
#[cfg(feature = "subdb")]
#[cfg(feature = "with-subdb")]
mod subdb;
use std::sync::Arc;
@@ -91,7 +91,7 @@ use log::{trace, debug, warn};
pub use sp_database::Database;
pub use sc_state_db::PruningMode;
#[cfg(any(feature = "kvdb-rocksdb", test))]
#[cfg(any(feature = "with-kvdb-rocksdb", test))]
pub use bench::BenchmarkingState;
const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768;
+10 -10
View File
@@ -36,7 +36,7 @@ use crate::{DatabaseSettings, DatabaseSettingsSrc, Database, DbHash};
/// Number of columns in the db. Must be the same for both full && light dbs.
/// Otherwise RocksDb will fail to open database && check its type.
#[cfg(any(feature = "kvdb-rocksdb", feature = "test-helpers", test))]
#[cfg(any(feature = "with-kvdb-rocksdb", feature = "test-helpers", test))]
pub const NUM_COLUMNS: u32 = 11;
/// Meta column. The set of keys in the column is shared by full && light storages.
pub const COLUMN_META: u32 = 0;
@@ -219,7 +219,7 @@ pub fn open_database<Block: BlockT>(
);
let db: Arc<dyn Database<DbHash>> = match &config.source {
#[cfg(any(feature = "kvdb-rocksdb", test))]
#[cfg(any(feature = "with-kvdb-rocksdb", test))]
DatabaseSettingsSrc::RocksDb { path, cache_size } => {
// first upgrade database to required version
crate::upgrade::upgrade_db::<Block>(&path, db_type)?;
@@ -255,27 +255,27 @@ pub fn open_database<Block: BlockT>(
.map_err(|err| sp_blockchain::Error::Backend(format!("{}", err)))?;
sp_database::as_database(db)
},
#[cfg(not(any(feature = "kvdb-rocksdb", test)))]
#[cfg(not(any(feature = "with-kvdb-rocksdb", test)))]
DatabaseSettingsSrc::RocksDb { .. } => {
return db_open_error("kvdb-rocksdb");
return db_open_error("with-kvdb-rocksdb");
},
#[cfg(feature = "subdb")]
#[cfg(feature = "with-subdb")]
DatabaseSettingsSrc::SubDb { path } => {
crate::subdb::open(&path, NUM_COLUMNS)
.map_err(|e| sp_blockchain::Error::Backend(format!("{:?}", e)))?
},
#[cfg(not(feature = "subdb"))]
#[cfg(not(feature = "with-subdb"))]
DatabaseSettingsSrc::SubDb { .. } => {
return db_open_error("subdb");
return db_open_error("with-subdb");
},
#[cfg(feature = "parity-db")]
#[cfg(feature = "with-parity-db")]
DatabaseSettingsSrc::ParityDb { path } => {
crate::parity_db::open(&path)
.map_err(|e| sp_blockchain::Error::Backend(format!("{:?}", e)))?
},
#[cfg(not(feature = "parity-db"))]
#[cfg(not(feature = "with-parity-db"))]
DatabaseSettingsSrc::ParityDb { .. } => {
return db_open_error("parity-db");
return db_open_error("with-parity-db");
},
DatabaseSettingsSrc::Custom(db) => db.clone(),
};
@@ -1,5 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "strict", deny(warnings))]
// Make the WASM binary available.
#[cfg(feature = "std")]
+1 -1
View File
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
default = ["db"]
# The RocksDB feature activates the RocksDB database backend. If it is not activated, and you pass
# a path to a database, an error will be produced at runtime.
db = ["sc-client-db/kvdb-rocksdb", "sc-client-db/parity-db"]
db = ["sc-client-db/with-kvdb-rocksdb", "sc-client-db/with-parity-db"]
wasmtime = [
"sc-executor/wasmtime",
]
+1 -1
View File
@@ -28,7 +28,7 @@ mod metrics;
pub mod error;
#[cfg(any(feature = "test-helpers", test))]
#[cfg(test)]
pub mod testing;
pub use sc_transaction_graph as txpool;
@@ -26,4 +26,4 @@ codec = { version = "1.3.0", package = "parity-scale-codec" }
[features]
default = ["db"]
db = ["sc-client-db/kvdb-rocksdb", "sc-client-db/parity-db"]
db = ["sc-client-db/with-kvdb-rocksdb", "sc-client-db/with-parity-db"]