Skip to content
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

Wallets load - remove refresh mechanism #12299

Merged
merged 6 commits into from
Jan 31, 2024
Merged

Conversation

molnard
Copy link
Collaborator

@molnard molnard commented Jan 23, 2024

Whenever wallets are enumerated in the WalletManager we also check if someone added a wallet file to the wallet folder. Wallets are enumerated tons of times, so the folder check is called many times. Enumerate files in a folder takes time it is an I/O operation - thus this is not performant, nor required.

Questions:

  1. Do we support the case if someone copies the wallet file into the Wallet folder and Wasabi should pick up the change on the fly? We have an official feature for this which is the Import wallet - we should encourage that by making everything else unconvinient or disabled. Also even if they copy the files manually after restarting Wasabi, files are picked up.

@molnard
Copy link
Collaborator Author

molnard commented Jan 26, 2024

Tested all the "add" scenarios - worked.

  • Add wallet - works
  • Import wallet - works
  • Recover wallet - works
  • Add hw wallet - works

@adamPetho
Copy link
Collaborator

Doesn't build ☹️

@turbolay
Copy link
Collaborator

diff --git a/WalletWasabi.Fluent/Helpers/WalletHelpers.cs b/WalletWasabi.Fluent/Helpers/WalletHelpers.cs
index 8ba1a23b48..c5dde28025 100644
--- a/WalletWasabi.Fluent/Helpers/WalletHelpers.cs
+++ b/WalletWasabi.Fluent/Helpers/WalletHelpers.cs
@@ -27,7 +27,7 @@ public static class WalletHelpers
        {
                var result = new List<LabelsByWallet>();
 
-               foreach (var wallet in Services.WalletManager.GetWallets(refreshWalletList: false))
+               foreach (var wallet in Services.WalletManager.GetWallets())
                {
                        var (changeLabels, receiveLabels) = wallet.KeyManager.GetLabels();
                        result.Add(new LabelsByWallet(wallet.WalletId, changeLabels, receiveLabels));

Copy link
Collaborator

@turbolay turbolay left a comment

Choose a reason for hiding this comment

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

tACK
I tried to see if it creates some problems but in fact, when touching wallet files, there are less issues on this branch rather than on master

I'd change the name of the function RefreshWalletList -> LoadWalletListFromFileSystem

Unrelated: It might be useful to verify integrity of the files when renaming (and disable the feature instead of creating a duplicate of the wallet file) and when quitting the software, even if I dont really know what to do if wallet files changed.

@@ -185,15 +185,10 @@ public void RenameWallet(Wallet wallet, string newWalletName)
return null;
}

public Task<IEnumerable<IWallet>> GetWalletsAsync() => Task.FromResult<IEnumerable<IWallet>>(GetWallets(refreshWalletList: true));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Refreshing wallets was true by default, now this behavior changed.

Out of 7 references 6 looks safe to me, but there is one instance, the RPC.
The RPC method listwallets was "refreshing"/ loading wallets from disk. With this PR it doesn't.

Perhaps we should update the RPC method to call WalletManager.RefreshWalletList manually.
WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's as safe as the other calls. I tested and had no issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When someone creates a wallet he/she should use the RPC as well and in that case it will be added.

Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

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

tACK, couldn't break the software

@molnard molnard merged commit d86bf81 into WalletWasabi:master Jan 31, 2024
6 of 7 checks passed
@molnard molnard deleted the noupdate branch January 31, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants