-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
refactor: Use util::Result class for wallet loading #25722
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 <[email protected]> bitcoin#25722 (comment) Co-authored-by: Martin Leitner-Ankerl <[email protected]>
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-
Add util::Result support for returning warning messages and multiple errors, not just a single error string. This provides a way for functions to report errors and warnings in a standard way, and simplifies interfaces. The functionality is unit tested here, and put to use in followup PR bitcoin#25722
Suggested by Martin Leitner-Ankerl <[email protected]> bitcoin#25722 (comment) Co-authored-by: Martin Leitner-Ankerl <[email protected]>
830570f
to
e2376f9
Compare
This is based on #25665 + #26022. The non-base commits are:
7665903504c1
Add temporary ResultExtract helper for porting to util::Resultc59404ce7406
refactor: Use util::Result class in wallet/sqlitecf327bffdca3
refactor: Use util::Result class in wallet/bdbfcb41875c379
refactor: Use util::Result class in wallet/migrate5ff81d94502a
refactor: Use util::Result class in wallet::MakeDatabase0afd7b55f857
refactor: Use util::Result class in wallet/dump3faa53122d45
refactor: Use util::Result class in wallet/salvage9319a3709b0c
refactor: Use util::Result class in wallet/wallettoolda907cbf01b6
refactor: Use util::Result class in wallet/walletfeace0a12121
refactor: Use util::Result class in wallet/load04185045dcf2
refactor: Use util::Result class in wallet/rpc3d657ccd02ad
refactor: Use util::Result class in wallet/interfacesab0476db30e1
refactor: Use util::Result class in wallet/testf193dfd14ebd
Drop temporary ResultExtract helper for porting to util::Resulte2376f9847c8
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.