diff --git a/libethcore/Ethash.cpp b/libethcore/Ethash.cpp index 163e1140b..db1a17b0a 100644 --- a/libethcore/Ethash.cpp +++ b/libethcore/Ethash.cpp @@ -140,7 +140,7 @@ void Ethash::CPUMiner::workLoop() unsigned hashCount = 1; for (; !shouldStop(); tryNonce++, hashCount++) { - ethashReturn = ethash_full_compute(dag->full, EthashAux::bytesToEthash256T(w.headerHash.data()), tryNonce); + ethashReturn = ethash_full_compute(dag->full, *(ethash_h256_t*)w.headerHash.data(), tryNonce); h256 value = h256((uint8_t*)ðashReturn.result, h256::ConstructFromPointer); if (value <= boundary && submitProof(Solution{(Nonce)(u64)tryNonce, h256((uint8_t*)ðashReturn.mix_hash, h256::ConstructFromPointer)})) break; diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index 0f4591d7d..8851f4c7b 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -41,20 +41,12 @@ using namespace chrono; using namespace dev; using namespace eth; - EthashAux* dev::eth::EthashAux::s_this = nullptr; EthashAux::~EthashAux() { } -ethash_h256_t EthashAux::bytesToEthash256T(uint8_t const* _bytes) -{ - ethash_h256_t ret; - memcpy(&ret, _bytes, 32); - return ret; -} - uint64_t EthashAux::cacheSize(BlockInfo const& _header) { return ethash_get_cachesize((uint64_t)_header.number); @@ -155,7 +147,7 @@ EthashAux::FullType EthashAux::full(uint64_t _blockNumber) Ethash::Result EthashAux::FullAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const { - ethash_return_value_t r = ethash_full_compute(full, bytesToEthash256T(_headerHash.data()), (uint64_t)(u64)_nonce); + ethash_return_value_t r = ethash_full_compute(full, *(ethash_h256_t*)_headerHash.data(), (uint64_t)(u64)_nonce); if (!r.success) BOOST_THROW_EXCEPTION(DAGCreationFailure()); return Ethash::Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)}; @@ -163,7 +155,7 @@ Ethash::Result EthashAux::FullAllocation::compute(h256 const& _headerHash, Nonce Ethash::Result EthashAux::LightAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const { - ethash_return_value r = ethash_light_compute(light, bytesToEthash256T(_headerHash.data()), (uint64_t)(u64)_nonce); + ethash_return_value r = ethash_light_compute(light, *(ethash_h256_t*)_headerHash.data(), (uint64_t)(u64)_nonce); if (!r.success) BOOST_THROW_EXCEPTION(DAGCreationFailure()); return Ethash::Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)}; diff --git a/libethcore/EthashAux.h b/libethcore/EthashAux.h index 6422f0db9..3a5abf3e3 100644 --- a/libethcore/EthashAux.h +++ b/libethcore/EthashAux.h @@ -58,7 +58,6 @@ public: using FullType = std::shared_ptr; static h256 seedHash(unsigned _number); - static ethash_h256_t bytesToEthash256T(uint8_t const* _bytes); static uint64_t cacheSize(BlockInfo const& _header); static LightType light(BlockInfo const& _header);