Browse Source

hash for two unit256

pull/19/head
orignal 7 years ago
parent
commit
484dd92a7c
  1. 8
      src/hash.cpp
  2. 3
      src/hash.h

8
src/hash.cpp

@ -1,5 +1,13 @@
#include "hash.h" #include "hash.h"
uint256 Hash (const uint256& left, const uint256& right)
{
uint8_t data[64];
memcpy (data, left.pn, 32);
memcpy (data + 32, right.pn, 32);
return Hash (data, data + 64);
}
inline uint32_t ROTL32 ( uint32_t x, int8_t r ) inline uint32_t ROTL32 ( uint32_t x, int8_t r )
{ {
return (x << r) | (x >> (32 - r)); return (x << r) | (x >> (32 - r));

3
src/hash.h

@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2009-2012 The Bitcoin developers
// Copyright (c) 2017 The Gostcoin developers
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_HASH_H #ifndef BITCOIN_HASH_H
@ -70,7 +71,6 @@ public:
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
inline uint256 Hash(const T1 p1begin, const T1 p1end, inline uint256 Hash(const T1 p1begin, const T1 p1end,
const T2 p2begin, const T2 p2end) const T2 p2begin, const T2 p2end)
@ -90,6 +90,7 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end,
return hash2; return hash2;
} }
uint256 Hash (const uint256& left, const uint256& right); // for Merkle tree
template<typename T> template<typename T>
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION) uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)

Loading…
Cancel
Save