refactor: rename will_reuse_cache to reallocate_cache
What changed, and why it matters
This commit is a simple rename of a function parameter from 'will_reuse_cache' to 'reallocate_cache' across five files. The actual behavior of the code does not change at all; only the name and related comments are updated to be clearer. There is no security impact.
No action required. This is a non-functional rename and can be treated as routine code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Pure refactoring commit. The boolean parameter to CCoinsViewCache::Flush is renamed from will_reuse_cache to reallocate_cache, with corresponding comment updates and call-site named-argument updates. The logic remains identical: when the parameter is true, ReallocateCache() is called after clearing the cache; when false, the memory footprint is retained. No functional or security changes.
Changed components
src/coins.cppsrc/coins.hsrc/test/fuzz/coins_view.cppsrc/test/fuzz/coinscache_sim.cppsrc/validation.cppInspect captured patch +9 / −9
diff --git a/src/coins.cpp b/src/coins.cpp
index 449adcde..6f9b5ed1 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -254,12 +254,12 @@ void CCoinsViewCache::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& ha
SetBestBlock(hashBlockIn);
}
-void CCoinsViewCache::Flush(bool will_reuse_cache)
+void CCoinsViewCache::Flush(bool reallocate_cache)
{
auto cursor{CoinsViewCacheCursor(m_sentinel, cacheCoins, /*will_erase=*/true)};
base->BatchWrite(cursor, hashBlock);
cacheCoins.clear();
- if (will_reuse_cache) {
+ if (reallocate_cache) {
ReallocateCache();
}
cachedCoinsUsage = 0;
diff --git a/src/coins.h b/src/coins.h
index f85ea5c9..d34196e5 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -446,10 +446,10 @@ public:
* Push the modifications applied to this cache to its base and wipe local state.
* Failure to call this method or Sync() before destruction will cause the changes
* to be forgotten.
- * If will_reuse_cache is false, the cache will retain the same memory footprint
+ * If reallocate_cache is false, the cache will retain the same memory footprint
* after flushing and should be destroyed to deallocate.
*/
- void Flush(bool will_reuse_cache = true);
+ void Flush(bool reallocate_cache = true);
/**
* Push the modifications applied to this cache to its base while retaining
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
index ed1e4078..699a45e2 100644
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -74,7 +74,7 @@ void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsView& backend
}
},
[&] {
- coins_view_cache.Flush(/*will_reuse_cache=*/fuzzed_data_provider.ConsumeBool());
+ coins_view_cache.Flush(/*reallocate_cache=*/fuzzed_data_provider.ConsumeBool());
},
[&] {
coins_view_cache.Sync();
diff --git a/src/test/fuzz/coinscache_sim.cpp b/src/test/fuzz/coinscache_sim.cpp
index 6894917e..5400cdf1 100644
--- a/src/test/fuzz/coinscache_sim.cpp
+++ b/src/test/fuzz/coinscache_sim.cpp
@@ -391,7 +391,7 @@ FUZZ_TARGET(coinscache_sim)
// Apply to simulation data.
flush();
// Apply to real caches.
- caches.back()->Flush(/*will_reuse_cache=*/provider.ConsumeBool());
+ caches.back()->Flush(/*reallocate_cache=*/provider.ConsumeBool());
},
[&]() { // Sync.
diff --git a/src/validation.cpp b/src/validation.cpp
index b505771e..b1a3ddd2 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2983,7 +2983,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
LogError("DisconnectTip(): DisconnectBlock %s failed\n", pindexDelete->GetBlockHash().ToString());
return false;
}
- view.Flush(/*will_reuse_cache=*/false); // local CCoinsViewCache goes out of scope
+ view.Flush(/*reallocate_cache=*/false); // local CCoinsViewCache goes out of scope
}
LogDebug(BCLog::BENCH, "- Disconnect block: %.2fms\n",
Ticks<MillisecondsDouble>(SteadyClock::now() - time_start));
@@ -3118,7 +3118,7 @@ bool Chainstate::ConnectTip(
Ticks<MillisecondsDouble>(time_3 - time_2),
Ticks<SecondsDouble>(m_chainman.time_connect_total),
Ticks<MillisecondsDouble>(m_chainman.time_connect_total) / m_chainman.num_blocks_total);
- view.Flush(/*will_reuse_cache=*/false); // No need to reallocate since it only has capacity for 1 block
+ view.Flush(/*reallocate_cache=*/false); // No need to reallocate since it only has capacity for 1 block
}
const auto time_4{SteadyClock::now()};
m_chainman.time_flush += time_4 - time_3;
@@ -4921,7 +4921,7 @@ bool Chainstate::ReplayBlocks()
}
cache.SetBestBlock(pindexNew->GetBlockHash());
- cache.Flush(/*will_reuse_cache=*/false); // local CCoinsViewCache goes out of scope
+ cache.Flush(/*reallocate_cache=*/false); // local CCoinsViewCache goes out of scope
m_chainman.GetNotifications().progress(bilingual_str{}, 100, false);
return true;
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.