Browse Source

Remove unneeded function for ethash to our h256 conversion

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
4134160f9a
  1. 2
      libethcore/Ethash.cpp
  2. 12
      libethcore/EthashAux.cpp
  3. 1
      libethcore/EthashAux.h

2
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*)&ethashReturn.result, h256::ConstructFromPointer);
if (value <= boundary && submitProof(Solution{(Nonce)(u64)tryNonce, h256((uint8_t*)&ethashReturn.mix_hash, h256::ConstructFromPointer)}))
break;

12
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)};

1
libethcore/EthashAux.h

@ -58,7 +58,6 @@ public:
using FullType = std::shared_ptr<FullAllocation>;
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);

Loading…
Cancel
Save