Browse Source

Fix mining. Again.

cl-refactor
Gav Wood 10 years ago
parent
commit
4251276cb3
  1. 2
      libethash/internal.c
  2. 8
      libethcore/Ethash.cpp
  3. 6
      libethcore/EthashAux.cpp

2
libethash/internal.c

@ -368,7 +368,7 @@ static bool ethash_mmap(struct ethash_full* ret, FILE* f)
if ((fd = ethash_fileno(ret->file)) == -1) { if ((fd = ethash_fileno(ret->file)) == -1) {
return false; return false;
} }
mmapped_data= mmap( mmapped_data = mmap(
NULL, NULL,
(size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE, (size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE,
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,

8
libethcore/Ethash.cpp

@ -142,8 +142,12 @@ void Ethash::CPUMiner::workLoop()
WorkPackage w = work(); WorkPackage w = work();
EthashAux::FullType dag; EthashAux::FullType dag;
while (!shouldStop() && !(dag = EthashAux::full(w.seedHash, true))) while (!shouldStop() && !dag)
this_thread::sleep_for(chrono::milliseconds(500)); {
while (!shouldStop() && EthashAux::computeFull(w.seedHash, true) != 100)
this_thread::sleep_for(chrono::milliseconds(500));
dag = EthashAux::full(w.seedHash, false);
}
h256 boundary = w.boundary; h256 boundary = w.boundary;
unsigned hashCount = 1; unsigned hashCount = 1;

6
libethcore/EthashAux.cpp

@ -133,7 +133,9 @@ bytesConstRef EthashAux::LightAllocation::data() const
EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb) EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb)
{ {
// cdebug << "About to call ethash_full_new...";
full = ethash_full_new(_light, _cb); full = ethash_full_new(_light, _cb);
// cdebug << "Called OK.";
if (!full) if (!full)
BOOST_THROW_EXCEPTION(ExternalFunctionFailure("ethash_full_new()")); BOOST_THROW_EXCEPTION(ExternalFunctionFailure("ethash_full_new()"));
} }
@ -170,9 +172,9 @@ EthashAux::FullType EthashAux::full(h256 const& _seedHash, bool _createIfMissing
if (_createIfMissing || computeFull(_seedHash, false) == 100) if (_createIfMissing || computeFull(_seedHash, false) == 100)
{ {
s_dagCallback = _f; s_dagCallback = _f;
cnote << "Loading from libethash..."; // cnote << "Loading from libethash...";
ret = make_shared<FullAllocation>(l->light, dagCallbackShim); ret = make_shared<FullAllocation>(l->light, dagCallbackShim);
cnote << "Done loading."; // cnote << "Done loading.";
DEV_GUARDED(get()->x_fulls) DEV_GUARDED(get()->x_fulls)
get()->m_fulls[_seedHash] = get()->m_lastUsedFull = ret; get()->m_fulls[_seedHash] = get()->m_lastUsedFull = ret;

Loading…
Cancel
Save