Changeset View
Changeset View
Standalone View
Standalone View
src/util/hasher.h
// Copyright (c) 2019 The Bitcoin Core developers | // Copyright (c) 2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT 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_UTIL_HASHER_H | #ifndef BITCOIN_UTIL_HASHER_H | ||||
#define BITCOIN_UTIL_HASHER_H | #define BITCOIN_UTIL_HASHER_H | ||||
#include <crypto/siphash.h> | #include <crypto/siphash.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <primitives/txid.h> | #include <primitives/txid.h> | ||||
#include <script/standard.h> | |||||
#include <uint256.h> | #include <uint256.h> | ||||
class SaltedUint256Hasher { | class SaltedUint256Hasher { | ||||
private: | private: | ||||
/** Salt */ | /** Salt */ | ||||
const uint64_t k0, k1; | const uint64_t k0, k1; | ||||
public: | public: | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | private: | ||||
const uint64_t m_k0, m_k1; | const uint64_t m_k0, m_k1; | ||||
public: | public: | ||||
SaltedSipHasher(); | SaltedSipHasher(); | ||||
size_t operator()(const Span<const uint8_t> &script) const; | size_t operator()(const Span<const uint8_t> &script) const; | ||||
}; | }; | ||||
struct TxDestinationHasher : SaltedSipHasher { | |||||
size_t operator()(const CTxDestination &dest) const { | |||||
return SaltedSipHasher::operator()(GetScriptForDestination(dest)); | |||||
} | |||||
}; | |||||
#endif // BITCOIN_UTIL_HASHER_H | #endif // BITCOIN_UTIL_HASHER_H |