move-only: hide coins cache internals #35180

pull l0rinc wants to merge 3 commits into bitcoin:master from l0rinc:l0rinc/hide-coins-cache-helpers changing 1 files +29 −31
  1. l0rinc commented at 8:49 AM on April 30, 2026: contributor

    Problem

    CCoinsViewCache exposes a few implementation details that are only used to maintain its own cache state. This makes the public interface broader than necessary, and leaves the class declaration split across repeated access sections.

    Fix

    Group the internal declarations in the default-private part of CCoinsViewCache, then move ReallocateCache() and ResetGuard out of the public interface.

    CreateResetGuard() remains public, so callers can still request scoped reset behavior without naming or constructing the guard type directly. Reset() remains protected for subclass-facing reset hooks.

  2. coins: group private cache declarations
    Move the private `FetchCoin()` declaration next to the default-private `CCoinsViewCache` members and rely on `class` default access for `m_deterministic`.
    This prepares the class layout for narrower helper visibility without leaving a trailing `private:` section.
    db4f8ef633
  3. coins: hide cache reallocation helper
    Move `ReallocateCache()` out of the public `CCoinsViewCache` interface.
    It is only called internally by `Flush()` when the cache map should release memory after clearing entries.
    08d669cc4e
  4. coins: hide cache reset guard
    Move `ResetGuard` out of the public `CCoinsViewCache` interface.
    Callers can still request scoped resets through `CreateResetGuard()` without naming the guard type directly.
    
    Leave `Reset()` protected as part of the subclass-facing reset hook surface.
    06040b4189
  5. DrahtBot added the label Refactoring on Apr 30, 2026
  6. DrahtBot commented at 8:49 AM on April 30, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35180.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK optout21

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34132 (coins: drop error catcher, centralize fatal read handling by l0rinc)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  7. optout21 commented at 1:35 PM on April 30, 2026: contributor

    Concept ACK 06040b4189a0db9c43c5570e62b9292e609c247e

  8. in src/coins.h:395 in db4f8ef633
     391 | @@ -392,9 +392,14 @@ class CCoinsViewBacked : public CCoinsView
     392 |  /** CCoinsView that adds a memory cache for transactions to another CCoinsView */
     393 |  class CCoinsViewCache : public CCoinsViewBacked
     394 |  {
     395 | -private:
    


    optout21 commented at 2:20 PM on May 5, 2026:

    db4f8ef coins: group private cache declarations:

    I'd prefer keeping the explicit private, even though it's unnecessary

  9. optout21 commented at 2:23 PM on May 5, 2026: contributor

    ACK 06040b4189a0db9c43c5570e62b9292e609c247e

    A minor, move-only refactor to reduce visibility of some CCoinsViewCache members.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:52 UTC