diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-11 15:28:16 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-11 15:29:21 +0200 |
commit | 1b5723ee5748aed573c638cc3223e03e3087e275 (patch) | |
tree | dca8705e57bce9ab5807112020786b597113875d /src | |
parent | b1fdfc1a8c072f798305f21d5e69207c9e1bed89 (diff) | |
parent | 0000d8f727be937baa1499a6d15efa5a48b0ffdd (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/validation.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 4a6c4066fc..8066e6c7a8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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()); |