diff options
| author | Pieter Wuille <[email protected]> | 2014-07-10 17:35:22 +0200 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2014-07-11 16:44:53 +0200 |
| commit | d4d3fbd828a477e8459169a097d5f1bfb69c2781 (patch) | |
| tree | af5ca954ae1c347891905b459e9d30e858997f2c /src | |
| parent | Merge pull request #4347 (diff) | |
| download | discoin-d4d3fbd828a477e8459169a097d5f1bfb69c2781.tar.xz discoin-d4d3fbd828a477e8459169a097d5f1bfb69c2781.zip | |
Do not flush the cache after every block outside of IBD
Diffstat (limited to 'src')
| -rw-r--r-- | src/coins.cpp | 7 | ||||
| -rw-r--r-- | src/main.cpp | 2 |
2 files changed, 7 insertions, 2 deletions
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() { diff --git a/src/main.cpp b/src/main.cpp index a9c080ffa..80a6956d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1915,7 +1915,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C // Update the on-disk chain state. bool static WriteChainState(CValidationState &state) { static int64_t nLastWrite = 0; - if (!IsInitialBlockDownload() || pcoinsTip->GetCacheSize() > nCoinCacheSize || GetTimeMicros() > nLastWrite + 600*1000000) { + if (pcoinsTip->GetCacheSize() > nCoinCacheSize || (!IsInitialBlockDownload() && GetTimeMicros() > nLastWrite + 600*1000000)) { // Typical CCoins structures on disk are around 100 bytes in size. // Pushing a new one to the database can cause it to be written // twice (once in the log, and once in the tables). This is already |