-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Use util::Result class for wallet loading #25722
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
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/25722. ReviewsSee the guideline for information on the review process. 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. |
bc4172e
to
a09c21c
Compare
a09c21c
to
e7457d0
Compare
Suggested by Martin Leitner-Ankerl <martin.ankerl@gmail.com> bitcoin#25722 (comment) Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
The util::ResultPtr class is a wrapper for util::Result providing syntax sugar to make it less awkward to use with returned pointers. Instead of needing to be deferenced twice with **result or (*result)->member, it only needs to be dereferenced once with *result or result->member. Also when it is used in a boolean context, instead of evaluating to true when there is no error and the pointer is null, it evaluates to false so it is straightforward to determine whether the result points to something. This PR is only partial a solution to bitcoin#26004 because while it makes it easier to check for null pointer values, it does not make it impossible to return a null pointer value inside a successful result. It would be possible to enforce that successful results always contain non-null pointers by using a not_null type (bitcoin#24423) in combination with ResultPtr, though.
-BEGIN VERIFY SCRIPT- git grep -l DatabaseStatus src | xargs sed -i s/DatabaseStatus/DatabaseError/g sed -i '/^ SUCCESS,$/d' src/wallet/db.h -END VERIFY SCRIPT-
88dfdac
to
96f6613
Compare
🐙 This pull request conflicts with the target branch and needs rebase. |
This is based on #25665 + #26022. The non-base commits are:
7bbb37f95f66
Add temporary ResultExtract helper for porting to util::Resultdadd24c9c399
refactor: Use util::Result class in wallet/sqlited9d14d19bc4b
refactor: Use util::Result class in wallet/migrate4b38596b7b77
refactor: Use util::Result class in wallet::MakeDatabase739356926fde
refactor: Use util::Result class in wallet/dump595b349e1b84
refactor: Use util::Result class in wallet/wallettool7b0f6a7f2933
refactor: Use util::Result class in wallet/wallet198baa48646b
refactor: Use util::Result class in wallet/load70f53f9d0adb
refactor: Use util::Result class in wallet/rpc76f729cef797
refactor: Use util::Result class in wallet/interfaces1aef3de77466
refactor: Use util::Result class in wallet/testccb530a4c048
Drop temporary ResultExtract helper for porting to util::Result96f66136f028
scripted-diff: replace wallet DatabaseStatus with DatabaseErrorWallet loading functions up and down the stack have lots of error and warning parameters, and return error information in different ways. This PR makes them uniformly return
util::Result
, without changing behavior.