From 499637606d52013922056874f642f91f6f6941d7 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 15:08:18 +0100 Subject: [PATCH] DB directory versioning --- ethcore/src/client.rs | 9 ++++++++- ethcore/src/service.rs | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 6f688bd57..3a0309c1c 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -17,7 +17,7 @@ //! Blockchain database client. use util::*; -use rocksdb::{Options, DB}; +use rocksdb::{Options, DB, DBCompactionStyle}; use blockchain::{BlockChain, BlockProvider, CacheSize}; use views::BlockView; use error::*; @@ -163,16 +163,23 @@ pub struct Client { } const HISTORY: u64 = 1000; +const CLIENT_DB_VER_STR: &'static str = "1.0"; impl Client { /// Create a new client with given spec and DB path. pub fn new(spec: Spec, path: &Path, message_channel: IoChannel ) -> Result, Error> { + let mut dir = path.to_path_buf(); + dir.push(H64::from(spec.genesis_header().hash()).hex()); + //TODO: sec/fat: pruned/full versioning + dir.push(format!("v{}-sec-pruned", CLIENT_DB_VER_STR)); + let path = dir.as_path(); let gb = spec.genesis_block(); let chain = Arc::new(RwLock::new(BlockChain::new(&gb, path))); let mut opts = Options::new(); opts.set_max_open_files(256); opts.create_if_missing(true); opts.set_use_fsync(false); + opts.set_compaction_style(DBCompactionStyle::DBUniversalCompaction); /* opts.set_bytes_per_sync(8388608); opts.set_disable_data_sync(false); diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 90fe0a6b5..92f483507 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -48,7 +48,6 @@ impl ClientService { info!("Configured for {} using {} engine", spec.name, spec.engine_name); let mut dir = env::home_dir().unwrap(); dir.push(".parity"); - dir.push(H64::from(spec.genesis_header().hash()).hex()); let client = try!(Client::new(spec, &dir, net_service.io().channel())); let client_io = Arc::new(ClientIoHandler { client: client.clone()