From 013935d1c05710749dc62ce85eb509ccac0de258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 24 May 2017 17:59:07 +0200 Subject: [PATCH] Get rid of Ethash wrapper --- ethminer/MinerAux.h | 4 ++-- libethcore/BlockInfo.h | 21 +++++++++++++++++++++ libethcore/EthashAux.cpp | 6 +----- libethcore/EthashAux.h | 31 +------------------------------ 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/ethminer/MinerAux.h b/ethminer/MinerAux.h index 438526b3b..f09bb6830 100644 --- a/ethminer/MinerAux.h +++ b/ethminer/MinerAux.h @@ -608,7 +608,7 @@ private: void doBenchmark(MinerType _m, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5) { - Ethash::BlockHeader genesis; + BlockHeader genesis; genesis.setNumber(m_benchmarkBlock); genesis.setDifficulty(1 << 18); cdebug << genesis.boundary(); @@ -674,7 +674,7 @@ private: void doSimulation(MinerType _m, int difficulty = 20) { - Ethash::BlockHeader genesis; + BlockHeader genesis; genesis.setNumber(m_benchmarkBlock); genesis.setDifficulty(1 << 18); cdebug << genesis.boundary(); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index ae56342c5..55bdf2b08 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -221,5 +221,26 @@ public: } }; +class BlockHeaderRaw: public BlockInfo +{ +public: + h256 const& seedHash() const; + Nonce const& nonce() const { return m_nonce; } + +protected: + BlockHeaderRaw() = default; + BlockHeaderRaw(BlockInfo const& _bi): BlockInfo(_bi) {} + + void clear() { m_mixHash = h256(); m_nonce = Nonce(); } + +private: + Nonce m_nonce; + h256 m_mixHash; + + mutable h256 m_seedHash; +}; + +using BlockHeader = BlockHeaderPolished; + } } diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index e83e8a493..6f22d7a38 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -49,17 +49,13 @@ const unsigned EthashProofOfWork::defaultGlobalWorkSizeMultiplier = 4096; // * C const unsigned EthashProofOfWork::defaultMSPerBatch = 0; const EthashProofOfWork::WorkPackage EthashProofOfWork::NullWorkPackage = EthashProofOfWork::WorkPackage(); -h256 const& Ethash::BlockHeaderRaw::seedHash() const +h256 const& BlockHeaderRaw::seedHash() const { if (!m_seedHash) m_seedHash = EthashAux::seedHash((unsigned)m_number); return m_seedHash; } -EthashAux::~EthashAux() -{ -} - EthashAux* EthashAux::get() { static std::once_flag flag; diff --git a/libethcore/EthashAux.h b/libethcore/EthashAux.h index 1970f0bea..a29c498fa 100644 --- a/libethcore/EthashAux.h +++ b/libethcore/EthashAux.h @@ -34,33 +34,6 @@ namespace eth struct DAGChannel: public LogChannel { static const char* name(); static const int verbosity = 1; }; -class Ethash -{ -public: - using Nonce = h64; - - class BlockHeaderRaw: public BlockInfo - { - - public: - h256 const& seedHash() const; - Nonce const& nonce() const { return m_nonce; } - - protected: - BlockHeaderRaw() = default; - BlockHeaderRaw(BlockInfo const& _bi): BlockInfo(_bi) {} - - void clear() { m_mixHash = h256(); m_nonce = Nonce(); } - - private: - Nonce m_nonce; - h256 m_mixHash; - - mutable h256 m_seedHash; - }; - using BlockHeader = BlockHeaderPolished; -}; - /// Proof of work definition for Ethash. struct EthashProofOfWork { @@ -79,7 +52,7 @@ struct EthashProofOfWork struct WorkPackage { WorkPackage() = default; - WorkPackage(Ethash::BlockHeader const& _bh) : + WorkPackage(BlockHeader const& _bh) : boundary(_bh.boundary()), headerHash(_bh.hashWithout()), seedHash(_bh.seedHash()) @@ -117,8 +90,6 @@ enum class DAGEraseMode class EthashAux { public: - ~EthashAux(); - static EthashAux* get(); struct LightAllocation