diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-11-06 15:22:45 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-11-06 15:36:20 +0100 |
commit | 880bc728b43f1ea3df690512087590270cf35601 (patch) | |
tree | 56ac6fec3bdb75177525b006beb44fb1fda50333 /src/hash.h | |
parent | cdddd177809d96f3df260a1797584707593460d1 (diff) | |
parent | fef5adcc331c4d7b92b71e03fc8a73343a865599 (diff) |
Merge #14074: Use std::unordered_set instead of set in blockfilter interface
fef5adcc331c4d7b92b71e03fc8a73343a865599 blockfilter: Use unordered_set instead of set in blockfilter. (Jim Posen)
4fb789e9b2ffdf48fd50293b3982b3fce4d5fbdf Extract CSipHasher to it's own file in crypto/ directory. (Jim Posen)
Pull request description:
Use `std::unordered_set` (hash set) instead of `std::set` (tree set) in blockfilter interface, as suggested by @ryanofsky in #12254. This may result in a very minor speedup, but I haven't measured.
This moves `CSipHasher` to it's own file `crypto/siphash.h`, so that it can be used in the libbitcoin_util library without including `hash.{h,cpp}`. I'm open to other suggestions on solving this issue if people would prefer to leave CSipHasher where it is.
Tree-SHA512: 593d1abda771e45f2860d5334272980d20df0b81925a402bb9ee875e17595c2517c0d8ac9c579218b84bbf66e15b49418241c1fe9f9265719bcd2377b0cd0d88
Diffstat (limited to 'src/hash.h')
-rw-r--r-- | src/hash.h | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/src/hash.h b/src/hash.h index 3534a400b3..6acab0b161 100644 --- a/src/hash.h +++ b/src/hash.h @@ -194,39 +194,4 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]); -/** SipHash-2-4 */ -class CSipHasher -{ -private: - uint64_t v[4]; - uint64_t tmp; - int count; - -public: - /** Construct a SipHash calculator initialized with 128-bit key (k0, k1) */ - CSipHasher(uint64_t k0, uint64_t k1); - /** Hash a 64-bit integer worth of data - * It is treated as if this was the little-endian interpretation of 8 bytes. - * This function can only be used when a multiple of 8 bytes have been written so far. - */ - CSipHasher& Write(uint64_t data); - /** Hash arbitrary bytes. */ - CSipHasher& Write(const unsigned char* data, size_t size); - /** Compute the 64-bit SipHash-2-4 of the data written so far. The object remains untouched. */ - uint64_t Finalize() const; -}; - -/** Optimized SipHash-2-4 implementation for uint256. - * - * It is identical to: - * SipHasher(k0, k1) - * .Write(val.GetUint64(0)) - * .Write(val.GetUint64(1)) - * .Write(val.GetUint64(2)) - * .Write(val.GetUint64(3)) - * .Finalize() - */ -uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256& val); -uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256& val, uint32_t extra); - #endif // BITCOIN_HASH_H |