Safe tor isolated streams.
MODIFY
WalletWasabi/Services/UpdateChecker.cs
WalletWasabi/Services/UpdateChecker.cs
@@ -14,15 +14,14 @@ namespace WalletWasabi.Services
{
Synchronizer = synchronizer;
UpdateStatus = new UpdateStatus(true, true, new Version(), 0);
-
+ WasabiClient = Synchronizer.WasabiClientFactory.NewBackendClient();
Synchronizer.PropertyChanged += Synchronizer_PropertyChanged;
}
public event EventHandler<UpdateStatus>? UpdateStatusChanged;
-
private WasabiSynchronizer Synchronizer { get; }
-
public UpdateStatus UpdateStatus { get; private set; }
+ public WasabiClient WasabiClient { get; }
private void Synchronizer_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
@@ -36,8 +35,7 @@ namespace WalletWasabi.Services
protected override async Task ActionAsync(CancellationToken cancel)
{
- using WasabiClient wasabiClient = Synchronizer.WasabiClientFactory.NewBackendClient();
- var newUpdateStatus = await wasabiClient.CheckUpdatesAsync(cancel).ConfigureAwait(false);
+ var newUpdateStatus = await WasabiClient.CheckUpdatesAsync(cancel).ConfigureAwait(false);
if (newUpdateStatus != UpdateStatus)
{
UpdateStatus = newUpdateStatus;
@@ -48,6 +46,7 @@ namespace WalletWasabi.Services
public override void Dispose()
{
Synchronizer.PropertyChanged -= Synchronizer_PropertyChanged;
+ WasabiClient.Dispose();
base.Dispose();
}
}

MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -42,6 +42,7 @@ namespace WalletWasabi.Services
_running = 0;
BitcoinStore = bitcoinStore;
WasabiClientFactory = wasabiClientFactory;
+ WasabiClient = wasabiClientFactory.NewBackendClient();
Cancel = new CancellationTokenSource();
}
@@ -57,6 +58,8 @@ namespace WalletWasabi.Services
public WasabiClientFactory WasabiClientFactory { get; }
+ public WasabiClient WasabiClient { get; }
+
public Network Network { get; private set; }
/// <summary>
@@ -161,8 +164,7 @@ namespace WalletWasabi.Services
return;
}
- using WasabiClient wasabiClient = WasabiClientFactory.NewBackendClient();
- response = await wasabiClient.GetSynchronizeAsync(hashChain.TipHash, maxFiltersToSyncAtInitialization, estimateMode, Cancel.Token)
+ response = await WasabiClient.GetSynchronizeAsync(hashChain.TipHash, maxFiltersToSyncAtInitialization, estimateMode, Cancel.Token)
.WithAwaitCancellationAsync(Cancel.Token, 300)
.ConfigureAwait(false);
@@ -191,9 +193,8 @@ namespace WalletWasabi.Services
BackendStatus = BackendStatus.NotConnected;
try
{
- using WasabiClient wasabiClient = WasabiClientFactory.NewBackendClient();
// Backend API version might be updated meanwhile. Trying to update the versions.
- var result = await wasabiClient.CheckUpdatesAsync(Cancel.Token).ConfigureAwait(false);
+ var result = await WasabiClient.CheckUpdatesAsync(Cancel.Token).ConfigureAwait(false);
// If the backend is compatible and the Api version updated then we just used the wrong API.
if (result.BackendCompatible && lastUsedApiVersion != WasabiClient.ApiVersion)
@@ -394,6 +395,7 @@ namespace WalletWasabi.Services
await Task.Delay(50).ConfigureAwait(false);
}
+ WasabiClient.Dispose();
Cancel?.Dispose();
EnableRequests(); // Enable requests (it's possible something is being blocked outside the class by AreRequestsBlocked.

Safe tor isolated streams.