diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -386,6 +386,7 @@ util/asmap.cpp util/bip32.cpp util/bytevectorhash.cpp + util/hasher.cpp util/error.cpp util/getuniquepath.cpp util/message.cpp @@ -496,7 +497,6 @@ rpc/rawtransaction_util.cpp rpc/util.cpp scheduler.cpp - salteduint256hasher.cpp versionbitsinfo.cpp warnings.cpp diff --git a/src/avalanche/peermanager.h b/src/avalanche/peermanager.h --- a/src/avalanche/peermanager.h +++ b/src/avalanche/peermanager.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -12,6 +12,7 @@ #include #include #include +#include #include // For ChainstateManager and cs_main #include diff --git a/src/avalanche/proofid.h b/src/avalanche/proofid.h --- a/src/avalanche/proofid.h +++ b/src/avalanche/proofid.h @@ -5,8 +5,8 @@ #ifndef BITCOIN_AVALANCHE_PROOFID_H #define BITCOIN_AVALANCHE_PROOFID_H -#include #include +#include #include diff --git a/src/chain.h b/src/chain.h --- a/src/chain.h +++ b/src/chain.h @@ -43,18 +43,6 @@ */ static constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60; -/** - * Maintain a map of CBlockIndex for all known headers. - */ -struct BlockHasher { - // this used to call `GetCheapHash()` in uint256, which was later moved; the - // cheap hash function simply calls ReadLE64() however, so the end result is - // identical - size_t operator()(const BlockHash &hash) const { - return ReadLE64(hash.begin()); - } -}; - extern RecursiveMutex cs_main; arith_uint256 GetBlockProof(const CBlockIndex &block); diff --git a/src/coins.h b/src/coins.h --- a/src/coins.h +++ b/src/coins.h @@ -7,10 +7,10 @@ #define BITCOIN_COINS_H #include -#include #include #include #include +#include #include #include @@ -69,36 +69,6 @@ } }; -class SaltedOutpointHasher { -private: - /** Salt */ - const uint64_t k0, k1; - -public: - SaltedOutpointHasher(); - - /** - * This *must* return size_t. With Boost 1.46 on 32-bit systems the - * unordered_map will behave unpredictably if the custom hasher returns a - * uint64_t, resulting in failures when syncing the chain (#4634). - * Note: This information above might be outdated as the unordered map - * container type has meanwhile been switched to the C++ standard library - * implementation. - * - * Having the hash noexcept allows libstdc++'s unordered_map to recalculate - * the hash during rehash, so it does not have to cache the value. This - * reduces node's memory by sizeof(size_t). The required recalculation has - * a slight performance penalty (around 1.6%), but this is compensated by - * memory savings of about 9% which allow for a larger dbcache setting. - * - * @see - * https://gcc.gnu.org/onlinedocs/gcc-9.2.0/libstdc++/manual/manual/unordered_associative.html - */ - size_t operator()(const COutPoint &outpoint) const noexcept { - return SipHashUint256Extra(k0, k1, outpoint.GetTxId(), outpoint.GetN()); - } -}; - /** * A Coin in one level of the coins database caching hierarchy. * diff --git a/src/coins.cpp b/src/coins.cpp --- a/src/coins.cpp +++ b/src/coins.cpp @@ -56,10 +56,6 @@ return base->EstimateSize(); } -SaltedOutpointHasher::SaltedOutpointHasher() - : k0(GetRand(std::numeric_limits::max())), - k1(GetRand(std::numeric_limits::max())) {} - CCoinsViewCache::CCoinsViewCache(CCoinsView *baseIn) : CCoinsViewBacked(baseIn), cachedCoinsUsage(0) {} diff --git a/src/index/blockfilterindex.h b/src/index/blockfilterindex.h --- a/src/index/blockfilterindex.h +++ b/src/index/blockfilterindex.h @@ -9,16 +9,11 @@ #include #include #include +#include /** Interval between compact filter checkpoints. See BIP 157. */ static constexpr int CFCHECKPT_INTERVAL = 1000; -struct FilterHeaderHasher { - size_t operator()(const uint256 &hash) const { - return ReadLE64(hash.begin()); - } -}; - /** * BlockFilterIndex is used to store and retrieve block filters, hashes, and * headers for a range of blocks by height. An index is constructed for each diff --git a/src/salteduint256hasher.h b/src/salteduint256hasher.h deleted file mode 100644 --- a/src/salteduint256hasher.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2018-2019 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_SALTEDUINT256HASHER_H -#define BITCOIN_SALTEDUINT256HASHER_H - -#include -#include - -class SaltedUint256Hasher { -private: - /** Salt */ - const uint64_t k0, k1; - -public: - SaltedUint256Hasher(); - - size_t hash(const uint256 &h) const { return SipHashUint256(k0, k1, h); } - size_t operator()(const uint256 &h) const { return hash(h); } -}; - -#endif // BITCOIN_SALTEDUINT256HASHER_H diff --git a/src/salteduint256hasher.cpp b/src/salteduint256hasher.cpp deleted file mode 100644 --- a/src/salteduint256hasher.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -SaltedUint256Hasher::SaltedUint256Hasher() - : k0(GetRand(std::numeric_limits::max())), - k1(GetRand(std::numeric_limits::max())) {} diff --git a/src/script/sigcache.h b/src/script/sigcache.h --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -7,6 +7,7 @@ #define BITCOIN_SCRIPT_SIGCACHE_H #include