refactor: rename `hashBlock` to `m_block_hash` to avoid shadowing
What changed, and why it matters
This is a simple code cleanup change that renames an internal variable from `hashBlock` to `m_block_hash` to avoid a naming conflict (shadowing) with a function parameter of the same name. No behavior changes, no security fix.
No security action needed. Treat as normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Pure refactor in CCoinsViewCache: renames the protected member hashBlock to m_block_hash and updates all references in src/coins.cpp and src/coins.h. The member is mutable uint256 and is used for caching the best block hash. The rename eliminates shadowing by the hashBlockIn parameter in SetBestBlock/BatchWrite. No functional or security changes.
Changed components
src/coins.cppsrc/coins.hCCoinsViewCacheInspect captured patch +7 / −7
diff --git a/src/coins.cpp b/src/coins.cpp
index 25b1ead0..5104b558 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -196,13 +196,13 @@ bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
}
uint256 CCoinsViewCache::GetBestBlock() const {
- if (hashBlock.IsNull())
- hashBlock = base->GetBestBlock();
- return hashBlock;
+ if (m_block_hash.IsNull())
+ m_block_hash = base->GetBestBlock();
+ return m_block_hash;
}
void CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
- hashBlock = hashBlockIn;
+ m_block_hash = hashBlockIn;
}
void CCoinsViewCache::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashBlockIn)
@@ -279,7 +279,7 @@ void CCoinsViewCache::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& ha
void CCoinsViewCache::Flush(bool reallocate_cache)
{
auto cursor{CoinsViewCacheCursor(m_dirty_count, m_sentinel, cacheCoins, /*will_erase=*/true)};
- base->BatchWrite(cursor, hashBlock);
+ base->BatchWrite(cursor, m_block_hash);
Assume(m_dirty_count == 0);
cacheCoins.clear();
if (reallocate_cache) {
@@ -291,7 +291,7 @@ void CCoinsViewCache::Flush(bool reallocate_cache)
void CCoinsViewCache::Sync()
{
auto cursor{CoinsViewCacheCursor(m_dirty_count, m_sentinel, cacheCoins, /*will_erase=*/false)};
- base->BatchWrite(cursor, hashBlock);
+ base->BatchWrite(cursor, m_block_hash);
Assume(m_dirty_count == 0);
if (m_sentinel.second.Next() != &m_sentinel) {
/* BatchWrite must clear flags of all entries */
diff --git a/src/coins.h b/src/coins.h
index 08c1886f..c0bf3c5a 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -374,7 +374,7 @@ protected:
* Make mutable so that we can "fill the cache" even from Get-methods
* declared as "const".
*/
- mutable uint256 hashBlock;
+ mutable uint256 m_block_hash;
mutable CCoinsMapMemoryResource m_cache_coins_memory_resource{};
/* The starting sentinel of the flagged entry circular doubly linked list. */
mutable CoinsCachePair m_sentinel;
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.