diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 3a0309c1c..ce176615d 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -155,8 +155,7 @@ impl ClientReport { pub struct Client { chain: Arc>, engine: Arc>, - state_db: Arc, - state_journal: Mutex, + state_db: Mutex, block_queue: RwLock, report: RwLock, import_lock: Mutex<()> @@ -209,8 +208,7 @@ impl Client { Ok(Arc::new(Client { chain: chain, engine: engine.clone(), - state_db: db.clone(), - state_journal: Mutex::new(JournalDB::new_with_arc(db)), + state_db: Mutex::new(state_db), block_queue: RwLock::new(BlockQueue::new(engine, message_channel)), report: RwLock::new(Default::default()), import_lock: Mutex::new(()), @@ -265,7 +263,7 @@ impl Client { } } - let db = self.state_journal.lock().unwrap().clone(); + let db = self.state_db.lock().unwrap().clone(); let result = match enact_verified(&block, self.engine.deref().deref(), db, &parent, &last_hashes) { Ok(b) => b, Err(e) => { @@ -302,7 +300,7 @@ impl Client { /// Get a copy of the best block's state. pub fn state(&self) -> State { - State::from_existing(JournalDB::new_with_arc(self.state_db.clone()), HeaderView::new(&self.best_block_header()).state_root(), self.engine.account_start_nonce()) + State::from_existing(self.state_db.lock().unwrap().clone(), HeaderView::new(&self.best_block_header()).state_root(), self.engine.account_start_nonce()) } /// Get info on the cache. diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index e805f0a60..d9d7b29cf 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -212,11 +212,9 @@ impl JournalDB { fn decrease_counters(keys: &[H256], counters: &mut HashMap) { for i in keys.iter() { let delete_counter = { - if let Some(mut cnt) = counters.get_mut(i) { - *cnt -= 1; - *cnt == 0 - } - else { false } + let cnt = counters.get_mut(i).expect("Missing key counter"); + *cnt -= 1; + *cnt == 0 }; if delete_counter { counters.remove(i);