Skip to content

Commit 1b5723e

Browse files
committed
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
2 parents b1fdfc1 + 0000d8f commit 1b5723e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/validation.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,9 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
20642064
* The caches and indexes are flushed depending on the mode we're called with
20652065
* if they're too large, if it's been a while since the last write,
20662066
* or always and in all cases if we're in prune mode and are deleting files.
2067+
*
2068+
* If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do anything
2069+
* besides checking if we need to prune.
20672070
*/
20682071
bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &state, FlushStateMode mode, int nManualPruneHeight) {
20692072
int64_t nMempoolUsage = mempool.DynamicMemoryUsage();
@@ -3454,8 +3457,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CVali
34543457
return AbortNode(state, std::string("System error: ") + e.what());
34553458
}
34563459

3457-
if (fCheckForPruning)
3458-
FlushStateToDisk(chainparams, state, FlushStateMode::NONE); // we just allocated more disk space for block files
3460+
FlushStateToDisk(chainparams, state, FlushStateMode::NONE);
34593461

34603462
CheckBlockIndex(chainparams.GetConsensus());
34613463

0 commit comments

Comments
 (0)