Extract the hard dependency on rocksdb from the light client (#8034)

* Extract the hard dependency on rocksdb from the light client

* Remove TODO
This commit is contained in:
Pierre Krieger
2018-03-01 19:53:15 +01:00
committed by Rando
parent ca0d1f5eb7
commit d4205da484
11 changed files with 59 additions and 78 deletions

View File

@@ -27,11 +27,10 @@ use ethereum_types::{H256, U256, Address};
use parking_lot::RwLock;
use journaldb;
use kvdb::DBValue;
use kvdb_rocksdb::{Database, DatabaseConfig};
use kvdb_memorydb;
use bytes::Bytes;
use rlp::*;
use ethkey::{Generator, Random};
use tempdir::TempDir;
use transaction::{self, Transaction, LocalizedTransaction, PendingTransaction, SignedTransaction, Action};
use blockchain::{TreeRoute, BlockReceipts};
use client::{
@@ -352,12 +351,10 @@ impl TestBlockChainClient {
}
}
pub fn get_temp_state_db() -> (StateDB, TempDir) {
let tempdir = TempDir::new("").unwrap();
let db = Database::open(&DatabaseConfig::with_columns(NUM_COLUMNS), tempdir.path().to_str().unwrap()).unwrap();
pub fn get_temp_state_db() -> StateDB {
let db = kvdb_memorydb::create(NUM_COLUMNS.unwrap_or(0));
let journal_db = journaldb::new(Arc::new(db), journaldb::Algorithm::EarlyMerge, COL_STATE);
let state_db = StateDB::new(journal_db, 1024 * 1024);
(state_db, tempdir)
StateDB::new(journal_db, 1024 * 1024)
}
impl MiningBlockChainClient for TestBlockChainClient {
@@ -370,8 +367,7 @@ impl MiningBlockChainClient for TestBlockChainClient {
fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
let engine = &*self.spec.engine;
let genesis_header = self.spec.genesis_header();
let (state_db, _tempdir) = get_temp_state_db();
let db = self.spec.ensure_db_good(state_db, &Default::default()).unwrap();
let db = self.spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = vec![genesis_header.hash()];
let mut open_block = OpenBlock::new(

View File

@@ -115,6 +115,8 @@ extern crate vm;
extern crate wasm;
extern crate memory_cache;
extern crate journaldb;
#[cfg(test)]
extern crate tempdir;
#[macro_use]
extern crate macros;
@@ -130,8 +132,6 @@ extern crate evm;
#[cfg(feature = "jit" )]
extern crate evmjit;
extern crate tempdir;
pub extern crate ethstore;
pub mod account_provider;