diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index 465ae17da..68c5f3057 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -138,12 +138,12 @@ EthashAux::LightAllocation::~LightAllocation() } -EthashAux::FullType EthashAux::full(BlockInfo const& _header, bytesRef _dest) +EthashAux::FullType EthashAux::full(BlockInfo const& _header, bytesRef _dest, bool _createIfMissing) { - return full(_header.seedHash(), _dest); + return full(_header.seedHash(), _dest, _createIfMissing); } -EthashAux::FullType EthashAux::full(h256 const& _seedHash, bytesRef _dest) +EthashAux::FullType EthashAux::full(h256 const& _seedHash, bytesRef _dest, bool _createIfMissing) { RecursiveGuard l(get()->x_this); FullType ret = get()->m_fulls[_seedHash].lock(); @@ -180,6 +180,8 @@ EthashAux::FullType EthashAux::full(h256 const& _seedHash, bytesRef _dest) bytesRef r = contentsNew(memoFile, _dest); if (!r) { + if (!_createIfMissing) + return FullType(); // file didn't exist. if (_dest) // buffer was passed in - no insertion into cache nor need to allocate @@ -221,8 +223,7 @@ Ethash::Result EthashAux::LightAllocation::compute(h256 const& _seedHash, h256 c Ethash::Result EthashAux::eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) { - // TODO: should be EthashAux::get()->haveFull(_seedHash) - if (auto dag = EthashAux::get()->full(_seedHash)) + if (auto dag = EthashAux::get()->full(_seedHash, bytesRef(), false)) return dag->compute(_seedHash, _headerHash, _nonce); return EthashAux::get()->light(_seedHash)->compute(_seedHash, _headerHash, _nonce); } diff --git a/libethcore/EthashAux.h b/libethcore/EthashAux.h index 98a6554ad..40dd88e16 100644 --- a/libethcore/EthashAux.h +++ b/libethcore/EthashAux.h @@ -60,8 +60,8 @@ public: static ethash_params params(unsigned _n); static LightType light(BlockInfo const& _header); static LightType light(h256 const& _seedHash); - static FullType full(BlockInfo const& _header, bytesRef _dest = bytesRef()); - static FullType full(h256 const& _header, bytesRef _dest = bytesRef()); + static FullType full(BlockInfo const& _header, bytesRef _dest = bytesRef(), bool _createIfMissing = true); + static FullType full(h256 const& _header, bytesRef _dest = bytesRef(), bool _createIfMissing = true); static Ethash::Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } static Ethash::Result eval(BlockInfo const& _header, Nonce const& _nonce);