Browse Source

Actually load the DAG.

cl-refactor
Gav Wood 10 years ago
parent
commit
c4df26e82e
  1. 2
      alethzero/MainWin.cpp
  2. 12
      ethminer/MinerAux.h
  3. 6
      libethcore/EthashAux.cpp
  4. 2
      libethcore/EthashAux.h

2
alethzero/MainWin.cpp

@ -1166,7 +1166,7 @@ void Main::on_turboMining_triggered()
void Main::refreshBlockChain() void Main::refreshBlockChain()
{ {
if (!ui->blocks->isVisible()) if (!ui->blocks->isVisible() || !isVisible())
return; return;
DEV_TIMED_FUNCTION; DEV_TIMED_FUNCTION;

12
ethminer/MinerAux.h

@ -388,7 +388,7 @@ private:
(void)_m; (void)_m;
(void)_remote; (void)_remote;
(void)_recheckPeriod; (void)_recheckPeriod;
#if ETH_JSONRPC || !ETH_TRUE #if ETH_JSONRPC || !ETH_TRUE
jsonrpc::HttpClient client(_remote); jsonrpc::HttpClient client(_remote);
Farm rpc(client); Farm rpc(client);
@ -399,7 +399,7 @@ private:
f.startGPU(); f.startGPU();
ProofOfWork::WorkPackage current; ProofOfWork::WorkPackage current;
EthashAux::FullType dag; EthashAux::FullType dag;
while (true) while (true)
try try
{ {
@ -418,9 +418,9 @@ private:
cnote << "Getting work package..."; cnote << "Getting work package...";
Json::Value v = rpc.eth_getWork(); Json::Value v = rpc.eth_getWork();
h256 hh(v[0].asString()); h256 hh(v[0].asString());
h256 newSeedHash(v[1].asString()); h256 newSeedHash(v[1].asString());
if (!(dag = EthashAux::full(newSeedHash, true))) if (!(dag = EthashAux::full(newSeedHash, true, [&](unsigned _pc){ cout << "\rCreating DAG. " << _pc << "% done..." << flush; return 0; })))
BOOST_THROW_EXCEPTION(DAGCreationFailure()); BOOST_THROW_EXCEPTION(DAGCreationFailure());
if (hh != current.headerHash) if (hh != current.headerHash)
{ {
current.headerHash = hh; current.headerHash = hh;
@ -459,7 +459,7 @@ private:
cerr << "JSON-RPC problem. Probably couldn't connect. Retrying in " << i << "... \r"; cerr << "JSON-RPC problem. Probably couldn't connect. Retrying in " << i << "... \r";
cerr << endl; cerr << endl;
} }
#endif #endif
exit(0); exit(0);
} }

6
libethcore/EthashAux.cpp

@ -167,7 +167,7 @@ EthashAux::FullType EthashAux::full(h256 const& _seedHash, bool _createIfMissing
return ret; return ret;
} }
if (_createIfMissing || computeFull(_seedHash) == 100) if (_createIfMissing || computeFull(_seedHash, false) == 100)
{ {
s_dagCallback = _f; s_dagCallback = _f;
cnote << "Loading from libethash..."; cnote << "Loading from libethash...";
@ -183,7 +183,7 @@ EthashAux::FullType EthashAux::full(h256 const& _seedHash, bool _createIfMissing
#define DEV_IF_THROWS(X) try { X; } catch (...) #define DEV_IF_THROWS(X) try { X; } catch (...)
unsigned EthashAux::computeFull(h256 const& _seedHash) unsigned EthashAux::computeFull(h256 const& _seedHash, bool _createIfMissing)
{ {
Guard l(get()->x_fulls); Guard l(get()->x_fulls);
uint64_t blockNumber; uint64_t blockNumber;
@ -199,7 +199,7 @@ unsigned EthashAux::computeFull(h256 const& _seedHash)
return 100; return 100;
} }
if (!get()->m_fullGenerator || !get()->m_fullGenerator->joinable()) if (_createIfMissing && (!get()->m_fullGenerator || !get()->m_fullGenerator->joinable()))
{ {
get()->m_fullProgress = 0; get()->m_fullProgress = 0;
get()->m_generatingFullNumber = blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH; get()->m_generatingFullNumber = blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH;

2
libethcore/EthashAux.h

@ -71,7 +71,7 @@ public:
static const uint64_t NotGenerating = (uint64_t)-1; static const uint64_t NotGenerating = (uint64_t)-1;
/// Kicks off generation of DAG for @a _seedHash and @returns false or @returns true if ready. /// Kicks off generation of DAG for @a _seedHash and @returns false or @returns true if ready.
static unsigned computeFull(h256 const& _seedHash); static unsigned computeFull(h256 const& _seedHash, bool _createIfMissing = true);
/// Information on the generation progress. /// Information on the generation progress.
static std::pair<uint64_t, unsigned> fullGeneratingProgress() { return std::make_pair(get()->m_generatingFullNumber, get()->m_fullProgress); } static std::pair<uint64_t, unsigned> fullGeneratingProgress() { return std::make_pair(get()->m_generatingFullNumber, get()->m_fullProgress); }
/// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result or empty pointer if not existing and _createIfMissing is false. /// Kicks off generation of DAG for @a _blocknumber and blocks until ready; @returns result or empty pointer if not existing and _createIfMissing is false.

Loading…
Cancel
Save