-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: Introduce AddressBookManager #25620
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
1) Call IsMine only once (instead of two). 2) Encode destination only once (instead of three). 3) Don't remove the entry from the map if db write failed. 4) Notify GUI only if removal succeeded
With Put, Find, Has and Delete methods (Same as it's implemented in the wallet)
Same flow as CWallet::SetAddressUsed and CWallet::IsAddressUsed
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
The first four commits seem fine and could stand alone, but I'm not sure that introducing an entire class for managing the address book is really necessary. I don't really see how it is more beneficial to have such a class vs just cleaning up existing address book access and making |
That point is more a "plus" than part of the short term benefits. The manager decoupling could worth it mainly for three reasons:
PD: we could still implement all of this inside the wallet class as well (including methods descriptions and what people shouldn't do), but.. is that the best for a maintainability point of view?. Shouldn't the wallet class ideally act more as a flow dispatcher, calling the appropriate classes/functions based on the contextual information? Saying that, I'm weighting approaches out loud.. I would be fine either way for this. Maybe it's too early to implement the |
ConceptACK. Separating this responsibility from @furszy I noticed that you left original methods to deal with address book in |
Yeah, I left them for two main reason: |
I don't think the presence of
I don't really think that having the separate class helps though. |
@achow101 why do you think no callers should have access to I agree that having proxy functions doesn't help with maintainability, but I'd just say we need to drop the wrappers in |
Have decoupled the commits that have no conceptual opposition within #26836. So we can move forward with them first. Afterwards, we can re-evaluate whether to rework this PR or not, based on a smaller set of patches. |
🐙 This pull request conflicts with the target branch and needs rebase. |
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
Are you still working on this? If not, maybe close for now |
closed for now |
Finishing the encapsulation work started in #25337. Please review #26836 first.
Context
We are currently using the address book for different purposes and features in the wallet such us:
Some of these points aren’t well known by many because this code has been spread and obfuscated across the wallet’s sources. (and created in a Frankenstein style).
PR Goals
Encapsulate the address book functionalities into its own
AddressBookManager
class, so we are able to distinguish properly the address book responsibilities and capabilities.Be able to decouple the address book dependency on the wallet’s main mutex (up to a certain point, because we are still using the same db connection).
Clean up the wallet sources further.
Be able to unit/fuzz test the address book manager implementation isolated from the wallet flows.
And create a new class that can be easily upgraded/replaced, and even different implementations can be used in parallel in different local wallets, by just providing a different manager instance to the wallet in the constructor.
Next steps
After this PR, will be working on improve the ‘change output’ flow which, at least for now, is strictly connected to this process (goal will be to remove the strict dependency).
Pending work (still under WIP, almost there)