diff options
author | Pieter Wuille <pieter@wuille.net> | 2023-02-01 18:52:11 -0500 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2023-02-02 09:00:15 -0500 |
commit | 59e6828bb5b56a2354a80059d3f660f551f3e207 (patch) | |
tree | f4b1749cca23c900c3d7d69b5615ae0afa8e2673 /src/coins.cpp | |
parent | b0ff31084006ac7d4a7afba3190ca75f5f8441af (diff) | |
download | bitcoin-59e6828bb5b56a2354a80059d3f660f551f3e207.tar.xz |
Add deterministic mode to CCoinsViewCache
Diffstat (limited to 'src/coins.cpp')
-rw-r--r-- | src/coins.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/coins.cpp b/src/coins.cpp index 8d99019bb0..5a6ae525a7 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -32,7 +32,10 @@ bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, std::unique_ptr<CCoinsViewCursor> CCoinsViewBacked::Cursor() const { return base->Cursor(); } size_t CCoinsViewBacked::EstimateSize() const { return base->EstimateSize(); } -CCoinsViewCache::CCoinsViewCache(CCoinsView* baseIn) : CCoinsViewBacked(baseIn) {} +CCoinsViewCache::CCoinsViewCache(CCoinsView* baseIn, bool deterministic) : + CCoinsViewBacked(baseIn), m_deterministic(deterministic), + cacheCoins(0, SaltedOutpointHasher(/*deterministic=*/deterministic)) +{} size_t CCoinsViewCache::DynamicMemoryUsage() const { return memusage::DynamicUsage(cacheCoins) + cachedCoinsUsage; @@ -311,7 +314,7 @@ void CCoinsViewCache::ReallocateCache() // Cache should be empty when we're calling this. assert(cacheCoins.size() == 0); cacheCoins.~CCoinsMap(); - ::new (&cacheCoins) CCoinsMap(); + ::new (&cacheCoins) CCoinsMap(0, SaltedOutpointHasher(/*deterministic=*/m_deterministic)); } void CCoinsViewCache::SanityCheck() const |