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 CoverageFor detailed information about the code coverage, see the test coverage report. 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
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 <martin.ankerl@gmail.com> bitcoin#25722 (comment) Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
ae0b9b8
to
5beaefa
Compare
Rebased 2385cb3 -> 987b28b ( |
🐙 This pull request conflicts with the target branch and needs rebase. |
This is based on #25665 + #26022. The non-base commits are:
1738717865a1
Add temporary ResultExtract helper for porting to util::Result8ff89ef65c81
refactor: Use util::Result class in wallet/sqlitec618a202c26f
refactor: Use util::Result class in wallet/bdb4bd92511f6d8
refactor: Use util::Result class in wallet::MakeDatabase2f72e6ced1bc
refactor: Use util::Result class in wallet/dumpd5209a03412c
refactor: Use util::Result class in wallet/salvagef30e4affc242
refactor: Use util::Result class in wallet/wallettool6d3a89fc8b57
refactor: Use util::Result class in wallet/wallet3d5f9240b590
refactor: Use util::Result class in wallet/load05e368eb6e8c
refactor: Use util::Result class in wallet/rpcf932c7c664d2
refactor: Use util::Result class in wallet/interfaces5aeaddda27f7
refactor: Use util::Result class in wallet/test2d9bc7c2a60f
Drop temporary ResultExtract helper for porting to util::Result5beaefaa806e
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.