Unify and limit rocksdb dependency places (#8371)

* secret_store: remove kvdb_rocksdb dependency

* cli: init db mod for open dispatch

* cli: move db, client_db, restoration_db, secretstore_db to a separate mod

* migration: rename to migration-rocksdb and remove ethcore-migrations

* ethcore: re-move kvdb-rocksdb dep to test

* mark test_helpers as test only and fix migration mod naming

* Move restoration_db_handler to test_helpers_internal

* Fix missing preambles in test_helpers_internal and rocksdb/helpers

* Move test crates downward

* Fix missing docs

* cli, db::open_db: move each argument to a separate line

* Use featuregate instead of dead code for `open_secretstore_db`

* Move pathbuf import to open_secretstore_db

Because it's only used there behind a feature gate
This commit is contained in:
Wei Tang
2018-04-14 03:14:53 +08:00
committed by Afri Schoedon
parent 3f677c6168
commit 897a94641e
27 changed files with 295 additions and 261 deletions

View File

@@ -92,7 +92,6 @@ extern crate ansi_term;
extern crate unexpected;
extern crate kvdb;
extern crate kvdb_memorydb;
extern crate kvdb_rocksdb;
extern crate util_error;
extern crate snappy;
@@ -128,6 +127,9 @@ extern crate evm;
pub extern crate ethstore;
#[cfg(test)]
extern crate kvdb_rocksdb;
pub mod account_provider;
pub mod block;
pub mod client;
@@ -167,6 +169,8 @@ mod tests;
#[cfg(test)]
#[cfg(feature="json-tests")]
mod json_tests;
#[cfg(test)]
mod test_helpers_internal;
pub use types::*;
pub use executive::contract_address;

View File

@@ -635,7 +635,7 @@ mod tests {
use snapshot::{ManifestData, RestorationStatus, SnapshotService};
use super::*;
use tempdir::TempDir;
use test_helpers::restoration_db_handler;
use test_helpers_internal::restoration_db_handler;
struct NoopDBRestore;
impl DatabaseRestore for NoopDBRestore {

View File

@@ -24,7 +24,8 @@ use ids::BlockId;
use snapshot::service::{Service, ServiceParams};
use snapshot::{self, ManifestData, SnapshotService};
use spec::Spec;
use test_helpers::{generate_dummy_client_with_spec_and_data, restoration_db_handler};
use test_helpers::generate_dummy_client_with_spec_and_data;
use test_helpers_internal::restoration_db_handler;
use io::IoChannel;
use kvdb_rocksdb::{Database, DatabaseConfig};

View File

@@ -35,11 +35,8 @@ use spec::Spec;
use state_db::StateDB;
use state::*;
use std::sync::Arc;
use std::path::Path;
use transaction::{Action, Transaction, SignedTransaction};
use views::BlockView;
use kvdb::{KeyValueDB, KeyValueDBHandler};
use kvdb_rocksdb::{Database, DatabaseConfig};
/// Creates test block with corresponding header
pub fn create_test_block(header: &Header) -> Bytes {
@@ -402,20 +399,3 @@ impl ChainNotify for TestNotify {
self.messages.write().push(data);
}
}
/// Creates new instance of KeyValueDBHandler
pub fn restoration_db_handler(config: DatabaseConfig) -> Box<KeyValueDBHandler> {
use kvdb::Error;
struct RestorationDBHandler {
config: DatabaseConfig,
}
impl KeyValueDBHandler for RestorationDBHandler {
fn open(&self, db_path: &Path) -> Result<Arc<KeyValueDB>, Error> {
Ok(Arc::new(Database::open(&self.config, &db_path.to_string_lossy())?))
}
}
Box::new(RestorationDBHandler { config })
}

View File

@@ -0,0 +1,39 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Internal helpers for client tests
use std::path::Path;
use std::sync::Arc;
use kvdb::{KeyValueDB, KeyValueDBHandler};
use kvdb_rocksdb::{Database, DatabaseConfig};
/// Creates new instance of KeyValueDBHandler
pub fn restoration_db_handler(config: DatabaseConfig) -> Box<KeyValueDBHandler> {
use kvdb::Error;
struct RestorationDBHandler {
config: DatabaseConfig,
}
impl KeyValueDBHandler for RestorationDBHandler {
fn open(&self, db_path: &Path) -> Result<Arc<KeyValueDB>, Error> {
Ok(Arc::new(Database::open(&self.config, &db_path.to_string_lossy())?))
}
}
Box::new(RestorationDBHandler { config })
}