From d4d3fbd828a477e8459169a097d5f1bfb69c2781 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 10 Jul 2014 17:35:22 +0200 Subject: Do not flush the cache after every block outside of IBD --- src/coins.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/coins.cpp') diff --git a/src/coins.cpp b/src/coins.cpp index 13a4ea95c..3ab03e047 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -107,7 +107,12 @@ bool CCoinsViewCache::SetCoins(const uint256 &txid, const CCoins &coins) { } bool CCoinsViewCache::HaveCoins(const uint256 &txid) { - return FetchCoins(txid) != cacheCoins.end(); + CCoinsMap::iterator it = FetchCoins(txid); + // We're using vtx.empty() instead of IsPruned here for performance reasons, + // as we only care about the case where an transaction was replaced entirely + // in a reorganization (which wipes vout entirely, as opposed to spending + // which just cleans individual outputs). + return (it != cacheCoins.end() && !it->second.vout.empty()); } uint256 CCoinsViewCache::GetBestBlock() { -- cgit v1.2.3