mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Add generic SaltedSipHasher
SaltedSipHasher is a generic hasher that can be used with most things we would hash in an unordered container.
This commit is contained in:
parent
95e61c1cf2
commit
210b693db6
2 changed files with 19 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -84,4 +84,16 @@ struct BlockHasher
|
|||
size_t operator()(const uint256& hash) const { return ReadLE64(hash.begin()); }
|
||||
};
|
||||
|
||||
class SaltedSipHasher
|
||||
{
|
||||
private:
|
||||
/** Salt */
|
||||
const uint64_t m_k0, m_k1;
|
||||
|
||||
public:
|
||||
SaltedSipHasher();
|
||||
|
||||
size_t operator()(const Span<const unsigned char>& script) const;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_UTIL_HASHER_H
|
||||
|
|
Loading…
Add table
Reference in a new issue