-
Notifications
You must be signed in to change notification settings - Fork 36.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove gArgs
from wallet.h
and wallet.cpp
#22183
Remove gArgs
from wallet.h
and wallet.cpp
#22183
Conversation
The effort here seems good, but it seems to me this approach adds as many (or more?) |
The idea of this PR is just to "move Your PR seems like a more robust approach to the problem. 👍 I'll try to have a look at #19101 the day after tomorrow. |
I guess it's possible the two PR's only overlap in some places and are mostly orthogonal since #19101 does not update the CWallet constructor and this PR does, but:
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
It seems so. I would like to avoid competing with your PR so I will try to review your PR tomorrow, I'll leave this PR as a draft and I'll try to make an alternative PR based on yours to show how it would look like. If anyone else has a different opinion on this, please share it to avoid unnecessary work. :) |
Thanks. Just to be clear about the previous comment #22183 (comment), I am saying I think the overlap between two PRs actually not so great, and my first suggestion there to avoid adding lots of new references to |
56bf005
to
1153ad3
Compare
@ryanofsky This PR is very modest follow-up to your #19101 at the moment as there are still some occurrences of To remove the rest of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 1153ad3, and this seems acceptable to merge even though it's still marked as draft. It also looks like it would be pretty straightforward to extend this and remove gArgs
from wallet/load.cpp (but it would require a rebase to avoid conflicts from recent #22217 merge).
To remove the rest of
gArgs
fromwallet.cpp
, it seems I would need to passWalletContext
parameter to aCWallet
constructor. I wonder what you think about this idea.
I think you could do this, but I'd suggest passing ArgsManager*
parameter instead of WalletContext
. In that case, it would also make sense to add a CWallet
ArgsManager* m_args
member.
The difference between passing ArgsManager*
and WalletContext
is not hugely significant, but I suggest it because the wallet context struct is really meant to hold the state needed to load/save/manage multiple wallets, and shouldn't be required to deal with just a single wallet. It's nice if CWallet objects don't have access to unnecessary state and less state is needed to create them.
(Related to the topic of ArgsManager cleanup @kiminuo, I'd also be happy if you could review #22766, in case you're inclined)
3ec555e
to
b1c01bc
Compare
I'll have a look. Thanks.
When passing
I'll attempt to have a look when I have a chance. |
Code review ACK b1c01bc. Only change since last review is using
|
b1c01bc
to
25de4e7
Compare
@ryanofsky I have added a commit that fixes this up. Thanks for the suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK c3c2132. Changes since last review: just rebasing and adding wallet load commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-review ACK c3c2132
As a side-thought, it seems like WalletContext could use an args-parameter constructor alternative.
c3c2132 Use `context.args` in `src/wallet/load.cpp`. (Kiminuo) 25de4e7 Use `context.args` in `CWallet::Create` instead of `gArgs`. (Kiminuo) aa5e7c9 Fix typo in bitcoin-cli.cpp (Kiminuo) Pull request description: The PR attempts to move us an inch towards the [goal](bitcoin#21244 (comment)) by using `WalletContext` in `wallet.{h|cpp}` code instead of relying on the global state (i.e. `gArgs`). Edit: The PR builds on bitcoin#19101. ACKs for top commit: ryanofsky: Code review ACK c3c2132. Changes since last review: just rebasing and adding wallet load commit Tree-SHA512: 2b436f5a219e32c2d529f55a89edca086d949396cebf9e089a21aa7b1c180e3c0fb17468f415dfc834f8e1614f8b3914c7e9a0bd33b95e7e0199c0dfe5ca9490
Saw this in IRC logs:
@achow101, it's intentional for CWallet not to have access to WalletContext. WalletContext is container for multiple wallets, and only meant to be used by RPC code and init code, not meant to be used by core wallet code. An individual CWallet is only meant to have access to the state it needs: a chain interface pointer, maybe an argsmanager pointer, it's own database, not to the list of other wallets or other global state. WalletContext is analogous to NodeContext. NodeContext is meant to be used by init and rpc code, not by validation code. Most normal code should not depend on or have access to the global state in these context structs. |
…llet.cpp` (2) 2ec38bd Remove `gArgs` from `wallet.h` and `wallet.cpp` (Kiminuo) Pull request description: This is a follow-up PR to bitcoin#22183 and is related to bitcoin#21005 issue. ACKs for top commit: ryanofsky: Code review ACK 2ec38bd. No changes since last review, just rebase Tree-SHA512: ae7fa1927b0a268f25697928ccaf1b3cf10ee1ccef3f9d2344001fbd7e11fe8ce768745c65e76bd7d1632c6c7650612b5b54eaf2be61093854f75a4c4dcb1784
The PR attempts to move us an inch towards the goal by using
WalletContext
inwallet.{h|cpp}
code instead of relying on the global state (i.e.gArgs
).Edit: The PR builds on #19101.