diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-07-09 17:25:09 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-07-14 16:13:08 +0200 |
commit | bc42503f6ab304608c321986a870795e45f5a016 (patch) | |
tree | cbb104bd5010fd817a460c89b10470e8b60f9ea7 /src/coins.cpp | |
parent | bdd5b587fc7fd1b4dda479c4aad15c874b22e8f3 (diff) |
Use unordered_map for CCoinsViewCache with salted hash
Diffstat (limited to 'src/coins.cpp')
-rw-r--r-- | src/coins.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/coins.cpp b/src/coins.cpp index 13a4ea95cd..e76d8c7ef2 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -4,6 +4,8 @@ #include "coins.h" +#include "random.h" + #include <assert.h> // calculate number of bytes for the bitmask, and its number of non-zero bytes @@ -69,6 +71,8 @@ void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; } bool CCoinsViewBacked::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { return base->BatchWrite(mapCoins, hashBlock); } bool CCoinsViewBacked::GetStats(CCoinsStats &stats) { return base->GetStats(stats); } +CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {} + CCoinsViewCache::CCoinsViewCache(CCoinsView &baseIn, bool fDummy) : CCoinsViewBacked(baseIn), hashBlock(0) { } bool CCoinsViewCache::GetCoins(const uint256 &txid, CCoins &coins) { @@ -84,8 +88,8 @@ bool CCoinsViewCache::GetCoins(const uint256 &txid, CCoins &coins) { } CCoinsMap::iterator CCoinsViewCache::FetchCoins(const uint256 &txid) { - CCoinsMap::iterator it = cacheCoins.lower_bound(txid); - if (it != cacheCoins.end() && it->first == txid) + CCoinsMap::iterator it = cacheCoins.find(txid); + if (it != cacheCoins.end()) return it; CCoins tmp; if (!base->GetCoins(txid,tmp)) |