Merge #11617: Avoid lock: Call FlushStateToDisk(...) regardless of fCheckForPruning

0000d8f Document how FlushStateMode::NONE is handled (practicalswift)
2311c7c Call FlushStateToDisk(...) regardless of fCheckForPruning (practicalswift)

Pull request description:

  FlushStateToDisk(...) won't do anything besides check if we need to prune if
  FLUSH_STATE_NONE is given. We avoid reading the variable fCheckForPruning
  which is guarded by the mutex cs_LastBlockFile.

Tree-SHA512: 89df06256f73503a74b9e26d580ce9ed09efaef347fae1ff6a5759a2993b0db52edd2fadb65694d27e579a5aed92127753bdf41b5bb1bd516e577fcf17f17999
This commit is contained in:
Wladimir J. van der Laan 2018-04-11 15:28:16 +02:00
commit 1b5723ee57
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
1 changed files with 4 additions and 2 deletions

View File

@ -2064,6 +2064,9 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
* The caches and indexes are flushed depending on the mode we're called with
* if they're too large, if it's been a while since the last write,
* or always and in all cases if we're in prune mode and are deleting files.
*
* If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do anything
* besides checking if we need to prune.
*/
bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &state, FlushStateMode mode, int nManualPruneHeight) {
int64_t nMempoolUsage = mempool.DynamicMemoryUsage();
@ -3454,8 +3457,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CVali
return AbortNode(state, std::string("System error: ") + e.what());
}
if (fCheckForPruning)
FlushStateToDisk(chainparams, state, FlushStateMode::NONE); // we just allocated more disk space for block files
FlushStateToDisk(chainparams, state, FlushStateMode::NONE);
CheckBlockIndex(chainparams.GetConsensus());