diff options
| author | Jim Posen <[email protected]> | 2018-08-20 23:35:29 -0700 |
|---|---|---|
| committer | Jim Posen <[email protected]> | 2018-11-05 09:30:56 -0800 |
| commit | fef5adcc331c4d7b92b71e03fc8a73343a865599 (patch) | |
| tree | abb6fd12e94870fba2b0343c46d107bc63934e75 /src/util/bytevectorhash.cpp | |
| parent | Extract CSipHasher to it's own file in crypto/ directory. (diff) | |
| download | discoin-fef5adcc331c4d7b92b71e03fc8a73343a865599.tar.xz discoin-fef5adcc331c4d7b92b71e03fc8a73343a865599.zip | |
blockfilter: Use unordered_set instead of set in blockfilter.
Diffstat (limited to 'src/util/bytevectorhash.cpp')
| -rw-r--r-- | src/util/bytevectorhash.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util/bytevectorhash.cpp b/src/util/bytevectorhash.cpp new file mode 100644 index 000000000..f87d0e04b --- /dev/null +++ b/src/util/bytevectorhash.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <crypto/siphash.h> +#include <random.h> +#include <util/bytevectorhash.h> + +ByteVectorHash::ByteVectorHash() +{ + GetRandBytes(reinterpret_cast<unsigned char*>(&m_k0), sizeof(m_k0)); + GetRandBytes(reinterpret_cast<unsigned char*>(&m_k1), sizeof(m_k1)); +} + +size_t ByteVectorHash::operator()(const std::vector<unsigned char>& input) const +{ + return CSipHasher(m_k0, m_k1).Write(input.data(), input.size()).Finalize(); +} |