This avoids the error
in-out param (and if warnings
is added to BResult
, it will avoid passing that in-out param as well).
Also, as it is needed for this change, prepare BResult
for non-copyable types.
This avoids the error
in-out param (and if warnings
is added to BResult
, it will avoid passing that in-out param as well).
Also, as it is needed for this change, prepare BResult
for non-copyable types.
Tested ACK https://github.com/bitcoin/bitcoin/pull/25594/commits/fa869c6df15a54dae0e8d6ba385514801ddd345f
Perhaps this change can be split into two commits: one for BResult and one for restoreWallet.
18@@ -18,9 +19,9 @@ class BResult {
19 std::variant<bilingual_str, T> m_variant;
20
21 public:
22- BResult() : m_variant(Untranslated("")) {}
23- BResult(const T& _obj) : m_variant(_obj) {}
In commit “refactor: Return BResult from restoreWallet” (fa869c6df15a54dae0e8d6ba385514801ddd345f)
I think dropping const T&
constructor drops support for noncopyable and nonmovable objects.
Maybe want:
0BResult(const T& obj) : m_variant{obj} {}
1BResult(T&& obj) : m_variant{std::move(obj)} {}
drops support
This was never supported, unless I am missing something?
Regardless, it seems wrong to return memory that is not owned. Though, if you really want to, it might be better to make the type T
explicit. That is, make it a a raw pointer/std::ref/span/string_view/whatever.
drops support
This was never supported, unless I am missing something?
You’re right. It didn’t work previously or in the version I suggested either. It would be possible, but would have to call one of the std::in_place_*
variant constructors here.
Regardless, it seems wrong to return memory that is not owned.
The idea would not to have BResult point to an outside value but for BResult to contain a value that is constructed in-place. But regardless, this is an edge case not worth considering here. I might support with it in my followup for #25308 and add a test if I do
reACK https://github.com/bitcoin/bitcoin/pull/25594/commits/fa475e9c7977a952617738f2ee8cf600c07d4df8
The previous commit, although it failed some CI checks, had worked on Ubuntu 21.10 clang version 13.0.0-2.
Maybe shared_ptr<CWallet> src/wallet/wallet.h:std::RestoreWallet(..,bilingual_str& error,...)
might also be changed to BResult<CWallet> src/wallet/wallet.h:std::RestoreWallet(..)
Maybe shared_ptr src/wallet/wallet.h:std::RestoreWallet(..,bilingual_str& error,…) might also be changed to BResult src/wallet/wallet.h:std::RestoreWallet(..)
Good idea. Feel free to ping me for review on a follow-up. For now I am trying to keep the changes here to a minimum.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, 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.
MarcoFalke
w0xlt
ryanofsky
DrahtBot
Labels
Wallet