Skip to content

Conversation

promag
Copy link
Contributor

@promag promag commented Mar 25, 2022

Don't extend shared ownership of all wallets to GetWalletForJSONRPCRequest scope.

Don't extend shared ownership of all wallets to GetWalletForJSONRPCRequest scope.
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK f59959e

The reasoning for this change, as far as I understood this PR, is this:

  • In the GetWalletForJSONRPCRequest function, we only needed the wallet shared pointer if the number of context wallets equals one. In other cases, we would like to return an error.
  • So for this, we would not like this function to have information about all the wallets corresponding to context.
  • That is why this PR suggests moving this process of unloading all wallets and returning a single one to a function in the wallet.cpp file.

I have checked that the changed code is clean and clear to reason with. And if my original understanding of this PR is correct, I think this PR can be merged. And in case my analysis was erroneous, please do correct me.

@achow101
Copy link
Member

What do you mean by "unload" in this context?

@promag
Copy link
Contributor Author

promag commented Apr 19, 2022

The actual wallet unload, which occurs on the last shared pointer.

@achow101
Copy link
Member

Oh, I see. Is there a scenario where this could actually happen, and if so, can we test for it?

@promag
Copy link
Contributor Author

promag commented Apr 19, 2022

Could happen when an explicit unload races with other call of any wallet. I don't think we can test without code changes.

@achow101
Copy link
Member

ACK f59959e

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept and code-review ACK f59959e

@fanquake fanquake merged commit 0ae0aa2 into bitcoin:master Aug 17, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 17, 2022
f59959e wallet: Prevent wallet unload on GetWalletForJSONRPCRequest (João Barbosa)

Pull request description:

  Don't extend shared ownership of all wallets to `GetWalletForJSONRPCRequest` scope.

ACKs for top commit:
  achow101:
    ACK f59959e
  shaavan:
    Code Review ACK f59959e
  theStack:
    Concept and code-review ACK f59959e

Tree-SHA512: 7c0294098b5c32acaab8cc6fcf17a581d580ad1a557ba0602a9506074ac035815739afb4a25b3e61be9132535c7fc3ec7ef5137c1dfc9d4078f13663d508ef55
@promag promag deleted the 2022-03-getwallets branch August 17, 2022 22:16
@bitcoin bitcoin locked and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants