From 1718d6c6486ca5ea9f346dd4eac0e5e42559fcd0 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 20 Jul 2015 14:51:40 +0200 Subject: [PATCH] ensurePrecomputed should respect --no-precompute --- libethcore/Ethash.cpp | 4 +++- libethcore/Ethash.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libethcore/Ethash.cpp b/libethcore/Ethash.cpp index f1149966a..538e56cdf 100644 --- a/libethcore/Ethash.cpp +++ b/libethcore/Ethash.cpp @@ -212,6 +212,8 @@ std::string Ethash::name() return "Ethash"; } +bool Ethash::s_precompute = false; + unsigned Ethash::revision() { return ETHASH_REVISION; @@ -219,7 +221,7 @@ unsigned Ethash::revision() void Ethash::ensurePrecomputed(unsigned _number) { - if (_number % ETHASH_EPOCH_LENGTH > ETHASH_EPOCH_LENGTH * 9 / 10) + if (s_precompute && _number % ETHASH_EPOCH_LENGTH > ETHASH_EPOCH_LENGTH * 9 / 10) // 90% of the way to the new epoch EthashAux::computeFull(EthashAux::seedHash(_number + ETHASH_EPOCH_LENGTH), true); } diff --git a/libethcore/Ethash.h b/libethcore/Ethash.h index 0ea80f5e1..de200b2bf 100644 --- a/libethcore/Ethash.h +++ b/libethcore/Ethash.h @@ -49,12 +49,14 @@ class EthashCLHook; class Ethash { public: + static bool s_precompute; static std::string name(); static unsigned revision(); static SealEngineFace* createSealEngine(); using Nonce = h64; + static void setPrecompute(bool _shouldPrecompute) { s_precompute = _shouldPrecompute; } static void manuallySubmitWork(SealEngineFace* _engine, h256 const& _mixHash, Nonce _nonce); static bool isWorking(SealEngineFace* _engine); static WorkingProgress workingProgress(SealEngineFace* _engine);