diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-05-04 01:38:08 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-05-11 17:57:27 -0700 |
commit | fc684ad8afae19c209701230837d338c5a6c1f72 (patch) | |
tree | 8be68e7cede23aa35c3cb3d5b24d60a67439bc86 | |
parent | 046392dc1dd965b4ec1ba60a14a714e3e3fa7a88 (diff) |
Use accurate memory for flushing decisions
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/main.h | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp index 47cbda32f5..e1b4e89901 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1067,7 +1067,7 @@ bool AppInit2(boost::thread_group& threadGroup) nTotalCache -= nBlockTreeDBCache; size_t nCoinDBCache = nTotalCache / 2; // use half of the remaining cache for coindb cache nTotalCache -= nCoinDBCache; - nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes + nCoinCacheUsage = nTotalCache; bool fLoaded = false; while (!fLoaded) { diff --git a/src/main.cpp b/src/main.cpp index 4f4926eb40..916e1a6093 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ bool fPruneMode = false; bool fIsBareMultisigStd = true; bool fCheckBlockIndex = false; bool fCheckpointsEnabled = true; -unsigned int nCoinCacheSize = 5000; +size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; /** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */ @@ -1894,7 +1894,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { } } if ((mode == FLUSH_STATE_ALWAYS) || - ((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->GetCacheSize() > nCoinCacheSize) || + ((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->DynamicMemoryUsage() > nCoinCacheUsage) || (mode == FLUSH_STATE_PERIODIC && GetTimeMicros() > nLastWrite + DATABASE_WRITE_INTERVAL * 1000000) || fFlushForPrune) { // Typical CCoins structures on disk are around 100 bytes in size. @@ -3197,7 +3197,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth } } // check level 3: check for inconsistencies during memory-only disconnect of tip blocks - if (nCheckLevel >= 3 && pindex == pindexState && (coins.GetCacheSize() + pcoinsTip->GetCacheSize()) <= nCoinCacheSize) { + if (nCheckLevel >= 3 && pindex == pindexState && (coins.DynamicMemoryUsage() + pcoinsTip->DynamicMemoryUsage()) <= nCoinCacheUsage) { bool fClean = true; if (!DisconnectBlock(block, state, pindex, coins, &fClean)) return error("VerifyDB(): *** irrecoverable inconsistency in block data at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); diff --git a/src/main.h b/src/main.h index 90b809e85e..2c4a4cb7cd 100644 --- a/src/main.h +++ b/src/main.h @@ -119,7 +119,7 @@ extern bool fTxIndex; extern bool fIsBareMultisigStd; extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled; -extern unsigned int nCoinCacheSize; +extern size_t nCoinCacheUsage; extern CFeeRate minRelayTxFee; /** Best header we've seen so far (used for getheaders queries' starting points). */ |