aboutsummaryrefslogtreecommitdiff
path: root/src/util/hasher.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-09-17 19:29:59 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-11-10 14:33:37 -0500
commit210b693db66e7c5b618014b5a287aee15af00045 (patch)
tree4615e9c69c139d3441d20b65011417a59ecb7cdf /src/util/hasher.cpp
parent95e61c1cf2a91d041c8025306ba36f0ea2806894 (diff)
Add generic SaltedSipHasher
SaltedSipHasher is a generic hasher that can be used with most things we would hash in an unordered container.
Diffstat (limited to 'src/util/hasher.cpp')
-rw-r--r--src/util/hasher.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/hasher.cpp b/src/util/hasher.cpp
index 236b8e926f..5900daf050 100644
--- a/src/util/hasher.cpp
+++ b/src/util/hasher.cpp
@@ -10,3 +10,10 @@
SaltedTxidHasher::SaltedTxidHasher() : k0(GetRand(std::numeric_limits<uint64_t>::max())), k1(GetRand(std::numeric_limits<uint64_t>::max())) {}
SaltedOutpointHasher::SaltedOutpointHasher() : k0(GetRand(std::numeric_limits<uint64_t>::max())), k1(GetRand(std::numeric_limits<uint64_t>::max())) {}
+
+SaltedSipHasher::SaltedSipHasher() : m_k0(GetRand(std::numeric_limits<uint64_t>::max())), m_k1(GetRand(std::numeric_limits<uint64_t>::max())) {}
+
+size_t SaltedSipHasher::operator()(const Span<const unsigned char>& script) const
+{
+ return CSipHasher(m_k0, m_k1).Write(script.data(), script.size()).Finalize();
+}