aboutsummaryrefslogtreecommitdiff
path: root/src/util/bytevectorhash.h
diff options
context:
space:
mode:
authorJim Posen <jim.posen@gmail.com>2018-08-20 23:35:29 -0700
committerJim Posen <jim.posen@gmail.com>2018-11-05 09:30:56 -0800
commitfef5adcc331c4d7b92b71e03fc8a73343a865599 (patch)
treeabb6fd12e94870fba2b0343c46d107bc63934e75 /src/util/bytevectorhash.h
parent4fb789e9b2ffdf48fd50293b3982b3fce4d5fbdf (diff)
blockfilter: Use unordered_set instead of set in blockfilter.
Diffstat (limited to 'src/util/bytevectorhash.h')
-rw-r--r--src/util/bytevectorhash.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/bytevectorhash.h b/src/util/bytevectorhash.h
new file mode 100644
index 0000000000..b88c17460b
--- /dev/null
+++ b/src/util/bytevectorhash.h
@@ -0,0 +1,26 @@
+// 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.
+
+#ifndef BITCOIN_UTIL_BYTEVECTORHASH_H
+#define BITCOIN_UTIL_BYTEVECTORHASH_H
+
+#include <stdint.h>
+#include <vector>
+
+/**
+ * Implementation of Hash named requirement for types that internally store a byte array. This may
+ * be used as the hash function in std::unordered_set or std::unordered_map over such types.
+ * Internally, this uses a random instance of SipHash-2-4.
+ */
+class ByteVectorHash final
+{
+private:
+ uint64_t m_k0, m_k1;
+
+public:
+ ByteVectorHash();
+ size_t operator()(const std::vector<unsigned char>& input) const;
+};
+
+#endif // BITCOIN_UTIL_BYTEVECTORHASH_H