Merge bitcoin/bitcoin#35180: coins: group private cache helpers
What changed, and why it matters
This change is purely a code cleanup: it moves two internal helper functions of a Bitcoin Core cache class into the private section of the class and removes a duplicate 'private:' label. There is no change to what the code does, no bug fix, and no security impact.
No action needed; this is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors CCoinsViewCache in src/coins.h by moving ReallocateCache() and FetchCoin() into the existing private section at the top of the class. ReallocateCache() was previously public, and FetchCoin() was already private but declared at the bottom. The change only affects access specifier placement and declaration order; no logic, signatures, or behavior are modified.
Changed components
src/coins.hInspect captured patch +13 / −14
### src/coins.h
@@ -438,6 +438,19 @@ class CCoinsViewCache : public CCoinsViewBacked
private:
const bool m_deterministic;
+ //! Force a reallocation of the cache map. This is required when downsizing
+ //! the cache because the map's allocator may be hanging onto a lot of
+ //! memory despite having called .clear().
+ //!
+ //! See: https://stackoverflow.com/questions/42114044/how-to-release-unordered-map-memory
+ void ReallocateCache();
+
+ /**
+ * @note this is marked const, but may actually append to `cacheCoins`, increasing
+ * memory usage.
+ */
+ CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const;
+
protected:
/**
* Make mutable so that we can "fill the cache" even from Get-methods
@@ -555,13 +568,6 @@ class CCoinsViewCache : public CCoinsViewBacked
//! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const;
- //! Force a reallocation of the cache map. This is required when downsizing
- //! the cache because the map's allocator may be hanging onto a lot of
- //! memory despite having called .clear().
- //!
- //! See: https://stackoverflow.com/questions/42114044/how-to-release-unordered-map-memory
- void ReallocateCache();
-
//! Run an internal sanity check on the cache data structure. */
void SanityCheck() const;
@@ -583,13 +589,6 @@ class CCoinsViewCache : public CCoinsViewBacked
//! Create a scoped guard that will call `Reset()` on this cache when it goes out of scope.
[[nodiscard]] ResetGuard CreateResetGuard() noexcept { return ResetGuard{*this}; }
-
-private:
- /**
- * @note this is marked const, but may actually append to `cacheCoins`, increasing
- * memory usage.
- */
- CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const;
};
/**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.