From dadc2a96eafac3a72bef19d84f40357adbcf6032 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 3 Mar 2016 12:39:19 +0100 Subject: [PATCH 1/2] shrink_to_fit after removing hashes. --- ethcore/src/blockchain/blockchain.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 185bcaad3..eac6da6a2 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -759,6 +759,14 @@ impl BlockChain { // TODO: handle block_hashes properly. block_hashes.clear(); + + blocks.shrink_to_fit(); + block_details.shrink_to_fit(); + block_hashes.shrink_to_fit(); + transaction_addresses.shrink_to_fit(); + block_logs.shrink_to_fit(); + blocks_blooms.shrink_to_fit(); + block_receipts.shrink_to_fit(); } if self.cache_size().total() < self.max_cache_size { break; } } From f8dc1f2e3aa96283de3e16d3bbe1e2961b916836 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 3 Mar 2016 12:56:34 +0100 Subject: [PATCH 2/2] Avoid leaking block_details. Fixes #576 --- ethcore/src/blockchain/blockchain.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index eac6da6a2..f412a8240 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -448,7 +448,8 @@ impl BlockChain { let mut write_details = self.block_details.write().unwrap(); for (hash, details) in update.block_details.into_iter() { batch.put_extras(&hash, &details); - write_details.insert(hash, details); + write_details.insert(hash.clone(), details); + self.note_used(CacheID::Extras(ExtrasIndex::BlockDetails, hash)); } let mut write_receipts = self.block_receipts.write().unwrap();