diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index bbc40e66c..f5469ada8 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -87,6 +87,8 @@ public: bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } bool operator>=(FixedHash const& _c) const { return !operator<(_c); } + bool operator<=(FixedHash const& _c) const { return operator==(_c) || operator<(_c); } + bool operator>(FixedHash const& _c) const { return !operator<=(_c); } // The obvious binary operators. FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } diff --git a/libethash/ethash.h b/libethash/ethash.h index bc2f528ed..b96e6347d 100644 --- a/libethash/ethash.h +++ b/libethash/ethash.h @@ -25,6 +25,17 @@ #include #include "compiler.h" +#define ETHASH_REVISION 19 +#define ETHASH_DAGSIZE_BYTES_INIT 1073741824U // 2**30 +#define ETHASH_DAG_GROWTH 113000000U +#define ETHASH_EPOCH_LENGTH 30000U +#define ETHASH_MIX_BYTES 128 +#define ETHASH_DAG_PARENTS 256 +#define ETHASH_CACHE_ROUNDS 3 +#define ETHASH_ACCESSES 64 + +// ********************* +// TODO: Remove once other code moved over to compliant naming scheme. #define REVISION 19 #define DAGSIZE_BYTES_INIT 1073741824U // 2**30 #define DAG_GROWTH 113000000U @@ -33,6 +44,7 @@ #define DAG_PARENTS 256 #define CACHE_ROUNDS 3 #define ACCESSES 64 +// ********************* #ifdef __cplusplus extern "C" { diff --git a/libethcore/Ethasher.cpp b/libethcore/Ethasher.cpp index a09b82107..52a1d17d7 100644 --- a/libethcore/Ethasher.cpp +++ b/libethcore/Ethasher.cpp @@ -100,17 +100,19 @@ ethash_params Ethasher::params(unsigned _n) bool Ethasher::verify(BlockInfo const& _header) { - if (_header.number >= EPOCH_LENGTH * 2048) return false; - bigint boundary = (bigint(1) << 256) / _header.difficulty; - uint8_t quick_hash_out[32]; + if (_header.number >= ETHASH_EPOCH_LENGTH * 2048) + return false; + h256 boundary = u256((bigint(1) << 256) / _header.difficulty); + uint8_t quickHashOut[32]; ethash_quick_hash( - quick_hash_out, - _header.headerHash(WithoutNonce).data(), - (uint64_t) (u64) _header.nonce, - _header.mixHash.data() + quickHashOut, + _header.headerHash(WithoutNonce).data(), + (uint64_t)(u64)_header.nonce, + _header.mixHash.data() ); - h256 quick_hash_out256 = h256(quick_hash_out, h256::ConstructFromPointer); - if (quick_hash_out256 > boundary) return false; + h256 quickHashOut256 = h256(quickHashOut, h256::ConstructFromPointer); + if (quickHashOut256 > boundary) + return false; auto e = eval(_header, _header.nonce); return (u256)e.value <= boundary && e.mixHash == _header.mixHash; }