diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 3167cf4e3..768ed223f 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -599,9 +599,13 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const& if (common != last) { // Erase the number-lookup cache for the segment of the chain that we're reverting (if any). + unsigned n = number(route.front()); DEV_WRITE_GUARDED(x_blockHashes) - for (auto i = route.begin(); i != route.end() && *i != common; ++i) - m_blockHashes.erase(h256(u256(number(*i)))); + for (auto i = route.begin(); i != route.end() && *i != common; ++i, --n) + m_blockHashes.erase(h256(u256(n))); + DEV_WRITE_GUARDED(x_transactionAddresses) + m_transactionAddresses.clear(); // TODO: could perhaps delete them individually? + // If we are reverting previous blocks, we need to clear their blooms (in particular, to // rebuild any higher level blooms that they contributed to). clearBlockBlooms(number(common) + 1, number(last) + 1); @@ -636,7 +640,7 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const& } } // Collate transaction hashes and remember who they were. - h256s newTransactionAddresses; + //h256s newTransactionAddresses; { bytes blockBytes; RLP blockRLP(*i == _block.info.hash() ? _block.block : &(blockBytes = block(*i)));