diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs
index affc0b405..3506b8951 100644
--- a/ethcore/src/state_db.rs
+++ b/ethcore/src/state_db.rs
@@ -43,8 +43,6 @@ struct AccountCache {
// When changing the type of the values here, be sure to update `mem_used` and
// `new`.
accounts: LruCache
>,
- /// DB Code cache. Maps code hashes to shared bytes.
- code: MemoryLruCache>>,
/// Information on the modifications in recently committed blocks; specifically which addresses
/// changed in which block. Ordered by block number.
modifications: VecDeque,
@@ -95,6 +93,8 @@ pub struct StateDB {
db: Box,
/// Shared canonical state cache.
account_cache: Arc>,
+ /// DB Code cache. Maps code hashes to shared bytes.
+ code_cache: Arc>>>>,
/// Local dirty cache.
local_cache: Vec,
/// Shared account bloom. Does not handle chain reorganizations.
@@ -125,9 +125,9 @@ impl StateDB {
db: db,
account_cache: Arc::new(Mutex::new(AccountCache {
accounts: LruCache::new(cache_items),
- code: MemoryLruCache::new(code_cache_size),
modifications: VecDeque::new(),
})),
+ code_cache: Arc::new(Mutex::new(MemoryLruCache::new(code_cache_size))),
local_cache: Vec::new(),
account_bloom: Arc::new(Mutex::new(bloom)),
cache_size: cache_size,
@@ -320,6 +320,7 @@ impl StateDB {
StateDB {
db: self.db.boxed_clone(),
account_cache: self.account_cache.clone(),
+ code_cache: self.code_cache.clone(),
local_cache: Vec::new(),
account_bloom: self.account_bloom.clone(),
cache_size: self.cache_size,
@@ -334,6 +335,7 @@ impl StateDB {
StateDB {
db: self.db.boxed_clone(),
account_cache: self.account_cache.clone(),
+ code_cache: self.code_cache.clone(),
local_cache: Vec::new(),
account_bloom: self.account_bloom.clone(),
cache_size: self.cache_size,
@@ -352,10 +354,9 @@ impl StateDB {
pub fn mem_used(&self) -> usize {
// TODO: account for LRU-cache overhead; this is a close approximation.
self.db.mem_used() + {
- let cache = self.account_cache.lock();
-
- cache.code.current_size() +
- cache.accounts.len() * ::std::mem::size_of::