Browse Source

Coding standards and compile fix.

cl-refactor
Gav Wood 10 years ago
parent
commit
f7abe38243
  1. 2
      libdevcore/FixedHash.h
  2. 12
      libethash/ethash.h
  3. 20
      libethcore/Ethasher.cpp

2
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; }

12
libethash/ethash.h

@ -25,6 +25,17 @@
#include <stddef.h>
#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" {

20
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;
}

Loading…
Cancel
Save