diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-19 11:39:38 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-03-06 17:21:58 +0100 |
commit | 81aeb28436d847ed4e6bcda8c746a3e5631c7feb (patch) | |
tree | c59787dbd7315c10eea11b7ae31573bda6e7c05d | |
parent | dec84cae2a7534af95873d5d96e38ad96b447d52 (diff) |
src/primitives/block.cpp: endian compatibility in GetHash
-rw-r--r-- | src/primitives/block.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 3b4a360395..8338762a38 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -8,10 +8,22 @@ #include "hash.h" #include "tinyformat.h" #include "utilstrencodings.h" +#include "crypto/common.h" uint256 CBlockHeader::GetHash() const { +#if defined(WORDS_BIGENDIAN) + uint8_t data[80]; + WriteLE32(&data[0], nVersion); + memcpy(&data[4], hashPrevBlock.begin(), hashPrevBlock.size()); + memcpy(&data[36], hashMerkleRoot.begin(), hashMerkleRoot.size()); + WriteLE32(&data[68], nTime); + WriteLE32(&data[72], nBits); + WriteLE32(&data[76], nNonce); + return Hash(data, data + 80); +#else // Can take shortcut for little endian return Hash(BEGIN(nVersion), END(nNonce)); +#endif } uint256 CBlock::BuildMerkleTree(bool* fMutated) const |