diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 03c5c6525..832d9465f 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -522,16 +522,19 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db, bool _force) // Collate logs into blooms. h256s alteredBlooms; { - WriteGuard l(x_blocksBlooms); LogBloom blockBloom = bi.logBloom; blockBloom.shiftBloom<3>(sha3(bi.coinbaseAddress.ref())); - unsigned index = (unsigned)bi.number; - for (unsigned level = 0; level < c_bloomIndexLevels; level++, index /= c_bloomIndexSize) + + // Pre-memoize everything we need before locking x_blocksBlooms + for (unsigned level = 0, index = (unsigned)bi.number; level < c_bloomIndexLevels; level++, index /= c_bloomIndexSize) + blocksBlooms(chunkId(level, index / c_bloomIndexSize)); + + WriteGuard l(x_blocksBlooms); + for (unsigned level = 0, index = (unsigned)bi.number; level < c_bloomIndexLevels; level++, index /= c_bloomIndexSize) { unsigned i = index / c_bloomIndexSize; unsigned o = index % c_bloomIndexSize; alteredBlooms.push_back(chunkId(level, i)); - blocksBlooms(alteredBlooms.back()); m_blocksBlooms[alteredBlooms.back()].blooms[o] |= blockBloom; } } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index d73299877..3d9f17335 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -145,7 +145,7 @@ Client::Client(p2p::Host* _extNet, std::string const& _dbPath, WithExisting _for Client::Client(p2p::Host* _extNet, std::shared_ptr _gp, std::string const& _dbPath, WithExisting _forceAction, u256 _networkId, int _miners): Worker("eth"), m_vc(_dbPath), - m_bc(_dbPath, max(m_vc.action(), _forceAction), [](unsigned d, unsigned t){ cerr << "REVISING BLOCKCHAIN: Processed " << d << " of " << t << "..." << endl; }), + m_bc(_dbPath, max(m_vc.action(), _forceAction), [](unsigned d, unsigned t){ cerr << "REVISING BLOCKCHAIN: Processed " << d << " of " << t << "...\r"; }), m_gp(_gp), m_stateDB(State::openDB(_dbPath, max(m_vc.action(), _forceAction))), m_preMine(Address(), m_stateDB),