From 2311c7cc86b7d3ab4912601ea0c21cc81a9f5eec Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 6 Nov 2017 11:21:15 +0100 Subject: [PATCH 1/2] Call FlushStateToDisk(...) regardless of fCheckForPruning 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. --- src/validation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 4a6c4066fc..1ef57f878b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3454,8 +3454,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr& 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()); From 0000d8f727be937baa1499a6d15efa5a48b0ffdd Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 11 Apr 2018 12:45:59 +0200 Subject: [PATCH 2/2] Document how FlushStateMode::NONE is handled --- src/validation.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/validation.cpp b/src/validation.cpp index 1ef57f878b..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();