Browse Source

Fix issue of mining rejig happening iff chain changed AND none ready:

Two blocks are mined on the same parent in quick succession. First gets
imported alone, chain changes but there's another "ready" so mining
doesn't get rejigged. When the second gets imported soon after, it
doesn't change the chain and so mining still doesn't restart.
cl-refactor
Gav Wood 10 years ago
parent
commit
84b3ce298c
  1. 3
      libethcore/Farm.h
  2. 2
      libethereum/Client.cpp

3
libethcore/Farm.h

@ -68,6 +68,7 @@ public:
void setWork(WorkPackage const& _wp) void setWork(WorkPackage const& _wp)
{ {
WriteGuard l(x_minerWork); WriteGuard l(x_minerWork);
cdebug << "Farm::setWork()";
if (_wp.headerHash == m_work.headerHash) if (_wp.headerHash == m_work.headerHash)
return; return;
m_work = _wp; m_work = _wp;
@ -94,6 +95,7 @@ public:
void stop() void stop()
{ {
WriteGuard l(x_minerWork); WriteGuard l(x_minerWork);
cdebug << "Farm::stop()";
m_miners.clear(); m_miners.clear();
m_work.reset(); m_work.reset();
m_isMining = false; m_isMining = false;
@ -175,6 +177,7 @@ private:
bool start() bool start()
{ {
WriteGuard l(x_minerWork); WriteGuard l(x_minerWork);
cdebug << "start()";
if (!m_miners.empty() && !!std::dynamic_pointer_cast<MinerType>(m_miners[0])) if (!m_miners.empty() && !!std::dynamic_pointer_cast<MinerType>(m_miners[0]))
return true; return true;
m_miners.clear(); m_miners.clear();

2
libethereum/Client.cpp

@ -702,7 +702,7 @@ void Client::onChainChanged(ImportRoute const& _ir)
// RESTART MINING // RESTART MINING
if (!m_bq.items().first) if (!isSyncing())
{ {
bool preChanged = false; bool preChanged = false;
State newPreMine; State newPreMine;

Loading…
Cancel
Save