Browse Source

Merge pull request #1952 from arkpar/bc

More block import optimizations
cl-refactor
Gav Wood 10 years ago
parent
commit
c4aef53b56
  1. 4
      libethcore/EthashAux.cpp
  2. 2
      libethcore/EthashAux.h
  3. 3
      libethereum/BlockChain.cpp
  4. 4
      libethereum/BlockQueue.cpp

4
libethcore/EthashAux.cpp

@ -101,13 +101,13 @@ uint64_t EthashAux::number(h256 const& _seedHash)
void EthashAux::killCache(h256 const& _s)
{
RecursiveGuard l(x_lights);
WriteGuard l(x_lights);
m_lights.erase(_s);
}
EthashAux::LightType EthashAux::light(h256 const& _seedHash)
{
RecursiveGuard l(get()->x_lights);
ReadGuard l(get()->x_lights);
LightType ret = get()->m_lights[_seedHash];
return ret ? ret : (get()->m_lights[_seedHash] = make_shared<LightAllocation>(_seedHash));
}

2
libethcore/EthashAux.h

@ -88,7 +88,7 @@ private:
static EthashAux* s_this;
RecursiveMutex x_lights;
SharedMutex x_lights;
std::unordered_map<h256, std::shared_ptr<LightAllocation>> m_lights;
Mutex x_fulls;

3
libethereum/BlockChain.cpp

@ -317,7 +317,8 @@ tuple<h256s, h256s, bool> BlockChain::sync(BlockQueue& _bq, OverlayDB const& _st
{
try
{
auto r = import(block.first, block.second, _stateDB);
// Nonce is already verified thread at this point.
auto r = import(block.first, block.second, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidNonce);
fresh += r.first;
dead += r.second;
}

4
libethereum/BlockQueue.cpp

@ -38,7 +38,9 @@ const char* BlockQueueChannel::name() { return EthOrange "▣┅▶"; }
BlockQueue::BlockQueue()
{
for (unsigned i = 0; i < thread::hardware_concurrency(); ++i)
// Allow some room for other activity
unsigned verifierThreads = std::max(thread::hardware_concurrency(), 3U) - 2U;
for (unsigned i = 0; i < verifierThreads; ++i)
m_verifiers.emplace_back([=](){
setThreadName("verifier" + toString(i));
this->verifierBody();

Loading…
Cancel
Save