Browse Source

Avoid div by zero.

Always prepare work, even when not apparently mining.
cl-refactor
Gav Wood 10 years ago
parent
commit
3efa477be6
  1. 6
      eth/main.cpp
  2. 2
      libethcore/BlockInfo.cpp
  3. 6
      libethcore/Miner.h
  4. 6
      libethereum/Client.cpp

6
eth/main.cpp

@ -379,8 +379,8 @@ void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod)
{
current.headerHash = hh;
current.seedHash = h256(v[1].asString());
current.boundary = h256(v[2].asString());
cnote << "Got new work package.";
current.boundary = h256(fromHex(v[2].asString()), h256::AlignRight);
cnote << "Got work package:" << current.headerHash.abridged() << " < " << current.boundary;
f.setWork(current);
}
this_thread::sleep_for(chrono::milliseconds(_recheckPeriod));
@ -395,7 +395,7 @@ void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod)
}
catch (jsonrpc::JsonRpcException&)
{
for (auto i = 10; --i; this_thread::sleep_for(chrono::seconds(1)))
for (auto i = 3; --i; this_thread::sleep_for(chrono::seconds(1)))
cerr << "JSON-RPC problem. Probably couldn't connect. Retrying in " << i << "... \r";
cerr << endl;
}

2
libethcore/BlockInfo.cpp

@ -77,7 +77,7 @@ h256 const& BlockInfo::hash() const
h256 const& BlockInfo::boundary() const
{
if (!m_boundary)
if (!m_boundary && difficulty)
m_boundary = (h256)(u256)((bigint(1) << 256) / difficulty);
return m_boundary;
}

6
libethcore/Miner.h

@ -24,7 +24,9 @@
#include <thread>
#include <list>
#include <atomic>
#include <boost/timer.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/Log.h>
#include <libdevcore/Worker.h>
#include <libethcore/Common.h>
@ -105,8 +107,12 @@ public:
}
if (!!_work)
{
boost::timer t;
pause();
cdebug << "pause took" << t.elapsed();
t.restart();
kickOff();
cdebug << "kickOff took" << t.elapsed();
}
else if (!_work && !!old)
pause();

6
libethereum/Client.cpp

@ -530,15 +530,15 @@ void Client::onChainChanged(ImportRoute const& _ir)
void Client::onPostStateChanged()
{
cnote << "Post state changed: Restarting mining...";
if (isMining())
{
// if (isMining())
// {
{
WriteGuard l(x_postMine);
m_postMine.commitToMine(m_bc);
m_miningInfo = m_postMine.info();
}
m_farm.setWork(m_miningInfo);
}
// }
m_remoteWorking = false;
}

Loading…
Cancel
Save