refactor: Stop using gArgs global in system.cpp #27170

pull ryanofsky wants to merge 2 commits into bitcoin:master from ryanofsky:pr/nogarg changing 10 files +25 −23
  1. ryanofsky commented at 7:54 pm on February 27, 2023: contributor

    Most of the code in util/system.cpp that was hardcoded to use the global ArgsManager instance gArgs has been changed to stop using it (for example in #20092). But a few hardcoded references to gArgs remain. This commit removes the last ones so these functions aren’t reading or writing global state.

    Noticed these gArgs references while reviewing #27073

  2. refactor: Use new GetConfigFilePath function
    New function was introduced by willcl-ark <will@256k1.dev> in commit
    56e370fbb9413260723c598048392219b1055ad0 from
    https://github.com/bitcoin/bitcoin/pull/27073 and removes some duplicate code.
    b20b34f5b3
  3. refactor: Stop using gArgs global in system.cpp
    Most of the code in util/system.cpp that was hardcoded to use the global
    ArgsManager instance `gArgs` has been changed to work with explicit ArgsManager
    instances (for example in https://github.com/bitcoin/bitcoin/pull/20092). But a
    few hardcoded references to `gArgs` remain. This commit removes the last ones
    so these functions aren't reading or writing global state.
    9a9d5da11f
  4. DrahtBot commented at 7:54 pm on February 27, 2023: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK willcl-ark, stickies-v, achow101
    Concept ACK TheCharlatan, fanquake, hebasto

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #27150 (Deduplicate bitcoind and bitcoin-qt init code by ryanofsky)
    • #10102 (Multiprocess bitcoin by ryanofsky)

    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.

  5. DrahtBot added the label Refactoring on Feb 27, 2023
  6. TheCharlatan commented at 9:24 pm on February 27, 2023: contributor
    Concept ACK
  7. fanquake commented at 9:27 am on February 28, 2023: member
    Concept ACK
  8. fanquake requested review from willcl-ark on Feb 28, 2023
  9. fanquake requested review from pinheadmz on Feb 28, 2023
  10. fanquake requested review from hebasto on Feb 28, 2023
  11. hebasto commented at 10:03 am on February 28, 2023: member
    Concept ACK.
  12. stickies-v commented at 10:17 am on February 28, 2023: contributor
    light code review ACK 9a9d5da11
  13. willcl-ark approved
  14. willcl-ark commented at 11:20 am on February 28, 2023: contributor

    tACK 9a9d5da11

    Tidy changes to remove the last references to global gArgs from util/system.cpp (besides the global declaration).

  15. in src/util/system.cpp:1071 in 9a9d5da11f
    1067@@ -1068,8 +1068,8 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
    1068     }
    1069 
    1070     // If datadir is changed in .conf file:
    1071-    gArgs.ClearPathCache();
    


    stickies-v commented at 12:09 pm on February 28, 2023:
    nit: Looks like this shouldn’t have been called on gArgs regardless of this PR, perhaps useful to split out in separate commit? In the 3 callsites of ArgsManager::ReadConfigFiles I see, it is only called on gArgs anyway, so I don’t see any actual behaviour change/potential bug because of it.
  16. stickies-v approved
  17. stickies-v commented at 12:11 pm on February 28, 2023: contributor
    ACK 9a9d5da11
  18. achow101 commented at 3:49 pm on February 28, 2023: member
    ACK 9a9d5da11fa6033f82dcf8e2298aee29587f5396
  19. achow101 merged this on Feb 28, 2023
  20. achow101 closed this on Feb 28, 2023

  21. sidhujag referenced this in commit 1a903b5264 on Mar 1, 2023
  22. hebasto referenced this in commit 372c571fda on Apr 23, 2023
  23. bitcoin locked this on Feb 28, 2024

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: 2024-07-03 10:13 UTC

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