txgraph: use enum Level instead of bool main_only #33354

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202509_txgraph_explicit_level changing 5 files +103 −105
  1. sipa commented at 7:57 PM on September 9, 2025: member

    Part of #30289. Inspired by #28676 (review).

    Since there has been more than one case in the development of #28676 of calling a TxGraph function without correctly setting the bool main_only argument that many of its interface functions have, make these mandatory and explicit, using an enum class Level:

    enum class Level {
        TOP, //!< Refers to staging if it exists, main otherwise.
        MAIN //!< Always refers to the main graph, whether staging is present or not.
    };
    
  2. DrahtBot commented at 7:57 PM on September 9, 2025: 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/33354.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK vasild, instagibbs, glozow

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33157 (cluster mempool: control/optimize TxGraph memory usage by sipa)

    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-->

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • "(which may be indicative of the transaction having been removed already." -> "(which may be indicative of the transaction having been removed already)." [Missing closing parenthesis makes the parenthetical unclosed and the sentence punctuation inconsistent.]

    <sup>drahtbot_id_5_m</sup>

  3. sipa force-pushed on Sep 9, 2025
  4. in src/test/fuzz/txgraph.cpp:1173 in b9af83e72c outdated
    1172 | -    for (int main_only = 0; main_only < 2; ++main_only) {
    1173 | -        auto& sim = main_only ? sims[0] : sims.back();
    1174 | +    // Try to run a full comparison, for both TxGraph::Level::MAIN and TxGraph::Level::TOP in
    1175 | +    // TxGraph inspector functions that support both.
    1176 | +    for (int level_select_int = 0; level_select_int < 2; ++level_select_int) {
    1177 | +        TxGraph::Level level = level_select_int == 0 ? TxGraph::Level::TOP : TxGraph::Level::MAIN;
    


    vasild commented at 8:24 AM on September 10, 2025:

    Can be written as:

    for (auto level : { TxGraph::Level::TOP, TxGraph::Level::MAIN }) {
    

    sipa commented at 12:03 PM on September 10, 2025:

    Indeed, done!

  5. vasild approved
  6. vasild commented at 9:14 AM on September 10, 2025: contributor

    ACK b9af83e72c60c1ee71251cf9f3dbae0ffccbe305

    Passing enum values with meaningful names seems better and more readable than passing true / false or omitting the argument.

  7. txgraph: use enum Level instead of bool main_only d45f3717d2
  8. sipa force-pushed on Sep 10, 2025
  9. vasild approved
  10. vasild commented at 12:12 PM on September 10, 2025: contributor

    ACK d45f3717d2c65d1a6012a4bc2f47ff75004fd171

  11. instagibbs commented at 12:32 PM on September 10, 2025: member

    concept ACK, having the two values was never confusing, it just took mental load to figure out what the implied argument meant in each context (and lead to bugs too)

  12. instagibbs commented at 1:08 PM on September 10, 2025: member

    ACK d45f3717d2c65d1a6012a4bc2f47ff75004fd171

    significantly easier to read usages, thank you

  13. glozow added the label Refactoring on Sep 11, 2025
  14. glozow commented at 2:59 PM on September 11, 2025: contributor

    code review ACK d45f3717d2c65d1a6012a4bc2f47ff75004fd171

  15. glozow merged this on Sep 11, 2025
  16. glozow closed this on Sep 11, 2025

  17. alexanderwiederin referenced this in commit 49e068b15b on Sep 16, 2025
  18. alexanderwiederin referenced this in commit 4b0c2f2a8f on Sep 17, 2025
  19. alexanderwiederin referenced this in commit 2edb618ffe on Sep 17, 2025
  20. stringintech referenced this in commit fb8510ba20 on Sep 17, 2025
  21. bug-castercv502 referenced this in commit 9f5d12d027 on Sep 28, 2025
  22. yuvicc referenced this in commit d89c6d0002 on Sep 28, 2025
  23. stickies-v referenced this in commit a785fe6759 on Nov 5, 2025
  24. Kino1994 referenced this in commit 0e898025c8 on Jun 28, 2026
  25. BigcoinBGC referenced this in commit c18062c97a on Jun 30, 2026
  26. Kino1994 referenced this in commit 6395a79a03 on Aug 19, 2026
  27. bitcoin locked this on Sep 11, 2026

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-09-20 21:52 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me