Browse Source

Merge pull request #4505

d4d3fbd Do not flush the cache after every block outside of IBD (Pieter Wuille)
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
2c0f019bfc
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 7
      src/coins.cpp
  2. 2
      src/main.cpp

7
src/coins.cpp

@ -111,7 +111,12 @@ bool CCoinsViewCache::SetCoins(const uint256 &txid, const CCoins &coins) {
} }
bool CCoinsViewCache::HaveCoins(const uint256 &txid) { 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() { uint256 CCoinsViewCache::GetBestBlock() {

2
src/main.cpp

@ -1918,7 +1918,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
// Update the on-disk chain state. // Update the on-disk chain state.
bool static WriteChainState(CValidationState &state) { bool static WriteChainState(CValidationState &state) {
static int64_t nLastWrite = 0; 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. // Typical CCoins structures on disk are around 100 bytes in size.
// Pushing a new one to the database can cause it to be written // 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 // twice (once in the log, and once in the tables). This is already

Loading…
Cancel
Save