-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Replace CWallet::Set* functions that use memonly with Add/Load variants #19046
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
Conversation
Remove the memonly bool and follow our typical Add and Load pattern.
Remove the memonly bool and follow the Add and Load pattern we use everywhere else.
I agree that having separate Add/Load functions instead of a confusing boolean argument improves understandability of the code quite a bit. |
Concept ACK |
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. |
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 f123374. Contra #19046 (comment) it seems good to me that these methods now try to update the wallet database first and return early on failure before updating the state in memory. Haven't thought about it too much but it seems better if that there's an error writing to disk for some reason, operation just fails and wallet stays in the current state.
@jnewbery, you may be interested in this PR since it was inspired by your review comment
Remove memonly bool and follow typical Add and Load pattern used everywhere else.
f123374
to
3a9aba2
Compare
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 3a9aba2
One small typo in a comment if you feel like retouching.
bool CWallet::AddWalletFlags(uint64_t flags) | ||
{ | ||
LOCK(cs_wallet); | ||
// We should never be writing unknown onon-tolerable wallet flags |
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.
s/onon/non/
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.
Oops. I'll fix that if I have to push again.
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 3a9aba2. Only changes since last review tweaks making m_wallet_flags updates more safe
{ | ||
LOCK(cs_wallet); | ||
// We should never be writing unknown onon-tolerable wallet flags | ||
assert(!(((flags & KNOWN_WALLET_FLAGS) >> 32) ^ (flags >> 32))); |
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.
In commit "Split SetWalletFlags into Add/LoadWalletFlags" (3a9aba2)
If you wind up updating check may be more readable as assert(((flags & KNOWN_WALLET_FLAGS) >> 32) == (flags >> 32))
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.
utACK 3a9aba2
… with Add/Load variants 3a9aba2 Split SetWalletFlags into Add/LoadWalletFlags (Andrew Chow) d9cd095 Split SetActiveScriptPubKeyMan into Add/LoadActiveScriptPubKeyMan (Andrew Chow) 0122fba Split SetHDChain into AddHDChain and LoadHDChain (Andrew Chow) Pull request description: `SetHDChaiin`, `SetActiveScriptPubKeyMan`, and `SetWalletFlags` have a `memonly` argument which is kind of confusing, as noted in bitcoin#17681 (comment). This PR replaces those functions with `Add*` and `Load*` variants so that they follow the pattern used elsewhere in the wallet. `AddHDChain`, `AddActiveScriptPubKeyMan`, and `AddWalletFlags` both set their respective variables in `CWallet` and writes them to disk. These functions are used by the actions which modify the wallet such as `sethdseed`, `importdescriptors`, and creating a new wallet. `LoadHDChain`, `LoadActiveScriptPubKeyMan`, and `LoadWalletFlags` just set the `CWallet` variables. These functions are used by `LoadWallet` when loading the wallet from disk. ACKs for top commit: jnewbery: Code review ACK 3a9aba2 ryanofsky: Code review ACK 3a9aba2. Only changes since last review tweaks making m_wallet_flags updates more safe meshcollider: utACK 3a9aba2 Tree-SHA512: 365aeaafc5ba42879c0eb797ec3beb29ab70e27f917dc880763f743420b3be6ddf797240996beed8a9ad70fb212c2590253c6b44c9dc244529c3939d9538983f
facd7dd wallet: Fix typo in comments; Simplify assert (MarcoFalke) Pull request description: Follow up to #19046 (comment) and #19046 (comment) ACKs for top commit: practicalswift: ACK facd7dd jonatack: ACK facd7dd hebasto: ACK facd7dd, spelling verified with `test/lint/lint-spelling.sh`: all remaining warnings are false positive. Tree-SHA512: 2b185d138058840db56726bb6bcc42e5288a954e2a410c49e04806a047fbbdaf0bb2decc70ecf7613c69caa766655705ca44151613e7ea5015b386d1e726d870
facd7dd wallet: Fix typo in comments; Simplify assert (MarcoFalke) Pull request description: Follow up to bitcoin#19046 (comment) and bitcoin#19046 (comment) ACKs for top commit: practicalswift: ACK facd7dd jonatack: ACK facd7dd hebasto: ACK facd7dd, spelling verified with `test/lint/lint-spelling.sh`: all remaining warnings are false positive. Tree-SHA512: 2b185d138058840db56726bb6bcc42e5288a954e2a410c49e04806a047fbbdaf0bb2decc70ecf7613c69caa766655705ca44151613e7ea5015b386d1e726d870
Summary: Remove the memonly bool and follow our typical Add and Load pattern. This is a backport of [[bitcoin/bitcoin#19046 | core#19046]] [1/3] bitcoin/bitcoin@0122fba Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D9630
Summary: Remove the memonly bool and follow the Add and Load pattern we use everywhere else. This is a backport of [[bitcoin/bitcoin#19046 | core#19046]] [2/3] bitcoin/bitcoin@d9cd095 Depends on D9630 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9631
Summary: Remove memonly bool and follow typical Add and Load pattern used everywhere else. This is a backport of [[bitcoin/bitcoin#19046 | core#19046]] [3/3] bitcoin/bitcoin@3a9aba2 Depends on D9631 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9632
SetHDChaiin
,SetActiveScriptPubKeyMan
, andSetWalletFlags
have amemonly
argument which is kind of confusing, as noted in #17681 (comment). This PR replaces those functions withAdd*
andLoad*
variants so that they follow the pattern used elsewhere in the wallet.AddHDChain
,AddActiveScriptPubKeyMan
, andAddWalletFlags
both set their respective variables inCWallet
and writes them to disk. These functions are used by the actions which modify the wallet such assethdseed
,importdescriptors
, and creating a new wallet.LoadHDChain
,LoadActiveScriptPubKeyMan
, andLoadWalletFlags
just set theCWallet
variables. These functions are used byLoadWallet
when loading the wallet from disk.