-
Notifications
You must be signed in to change notification settings - Fork 38.7k
qt: Use WalletModel* instead of the wallet name as map key #14784
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
Conversation
|
Concept ACK. Small nit for clarity's sake: would make sense to word the PR title and commit as "use WalletModel pointer as map key" instead of what is not used, this tells reviewers more. |
49f3dd7 to
492156b
Compare
|
@laanwj sure, actually the commit was already along that. @practicalswift done. |
|
Concept ACK. |
|
I'm not entirely convince that holding raw pointers in a list is an improvement. |
|
@jonasschnelli what are your concerns? |
I think the concern, versus using another kind of id, is that when using a pointer an inconsistency between the different data structures will cause crashes / use after free. |
|
Must be removed before free and we should be confident about that. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 492156b4b908ae1aa99b947a2efb314295d70749. This change looks like an improvement to me. Both pointers and strings should be unique but it seems easier to screw up string formatting and comparison than pointer equality checking.
In theory if there were use-after-free bugs we didn't know about, string comparisons could allow the code to limp along further without crashing, but I don't see where this could happen here because the pointers seem to be used for map lookups without getting dereferenced. Maybe you could replace WalletModel* with intptr_t to officially prevent dereferencing, though I think the WalletModel* is more obvious and easy to understand.
|
So is there no other suitable unique identifier except the pointer? I ask this because a remote RPC client would have to do with only the name too, right? |
|
Yes the RPC identifies the wallet by its name. |
I guess there's something to be said, then, for not ever changing that identifier while the wallet is loaded to avoid confusing remote clients, even if, say, the on-disk name or location changes. |
|
@laanwj my point is if there is a rename the WalletModel is the same. I'm not saying anything regarding RPC :) |
|
No, you don't say anything about RPC, but that the identifier should probably be constant while a wallet is loaded. Or does RPC use a different identifier for wallets than the GUI does? |
|
The public unique identifier is the wallet name but here Maybe I shouldn't bring up "wallet rename".. I just think using the |
492156b to
ac729ad
Compare
|
Rebased and also use |
|
travis fail: |
ac729ad to
dd39ca3
Compare
dd39ca3 to
3f427b4
Compare
3f427b4 to
91b0c5b
Compare
|
Thanks @laanwj, fixed now. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 91b0c5b. Changes since last review: rebase, adding new rpc console commit, and adding copyright year updates to earlier commits.
Not a big deal, but I think rpc console commit 91b0c5b goes a little too far in passing WalletModel to parse/execute functions which really only need a wallet name to pass along to the RPC engine, and not a full WalletModel instance. It might make this code slightly more difficult to separate and test.
|
@ryanofsky I had like that but RPC console already has |
91b0c5b qt: Use WalletModel* instead of wallet name in console window (João Barbosa) b2ce86c qt: Use WalletModel* instead of wallet name in main window (João Barbosa) d2a1adf qt: Factor out WalletModel::getDisplayName() (João Barbosa) Pull request description: This a small refactor that doesn't change behavior. This is also necessary if in the future we allow renaming wallets. Tree-SHA512: 1820d0ff28e84b1d862097f1f55b52f94520fa50c9b1939d235a448a48159748c3bbf99b19e4cb1ff4f91efc008c0971b4c25a91f645f9d43792c8aeaa93cf9e
…as map key 91b0c5b qt: Use WalletModel* instead of wallet name in console window (João Barbosa) b2ce86c qt: Use WalletModel* instead of wallet name in main window (João Barbosa) d2a1adf qt: Factor out WalletModel::getDisplayName() (João Barbosa) Pull request description: This a small refactor that doesn't change behavior. This is also necessary if in the future we allow renaming wallets. Tree-SHA512: 1820d0ff28e84b1d862097f1f55b52f94520fa50c9b1939d235a448a48159748c3bbf99b19e4cb1ff4f91efc008c0971b4c25a91f645f9d43792c8aeaa93cf9e
…as map key 91b0c5b qt: Use WalletModel* instead of wallet name in console window (João Barbosa) b2ce86c qt: Use WalletModel* instead of wallet name in main window (João Barbosa) d2a1adf qt: Factor out WalletModel::getDisplayName() (João Barbosa) Pull request description: This a small refactor that doesn't change behavior. This is also necessary if in the future we allow renaming wallets. Tree-SHA512: 1820d0ff28e84b1d862097f1f55b52f94520fa50c9b1939d235a448a48159748c3bbf99b19e4cb1ff4f91efc008c0971b4c25a91f645f9d43792c8aeaa93cf9e
This a small refactor that doesn't change behavior. This is also necessary if in the future we allow renaming wallets.