[skip ci] Improve wallet shutdown speed when internet is off
MODIFY
WalletWasabi/Services/UpdateChecker.cs
WalletWasabi/Services/UpdateChecker.cs
@@ -43,7 +43,7 @@ namespace WalletWasabi.Services
// If stop was requested return.
if (IsRunning == false) return;
- (bool backendCompatible, bool clientUpToDate) updates = await WasabiClient.CheckUpdatesAsync();
+ (bool backendCompatible, bool clientUpToDate) updates = await WasabiClient.CheckUpdatesAsync(Stop.Token);
if (!updates.backendCompatible)
{
@@ -57,10 +57,6 @@ namespace WalletWasabi.Services
await Task.Delay(period, Stop.Token);
}
- catch (TaskCanceledException ex)
- {
- Logger.LogTrace<UpdateChecker>(ex);
- }
catch (ConnectionException ex)
{
Logger.LogError<UpdateChecker>(ex);
@@ -74,11 +70,18 @@ namespace WalletWasabi.Services
}
}
catch (Exception ex)
+ {
+ if (ex is TaskCanceledException || ex is OperationCanceledException || ex is TimeoutException)
+ {
+ Logger.LogTrace<UpdateChecker>(ex);
+ }
+ else
{
Logger.LogDebug<UpdateChecker>(ex);
}
}
}
+ }
finally
{
if (IsStopping)

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -119,9 +119,9 @@ namespace WalletWasabi.WebClients.Wasabi
#region software
- public async Task<(Version ClientVersion, int BackendMajorVersion)> GetVersionsAsync()
+ public async Task<(Version ClientVersion, int BackendMajorVersion)> GetVersionsAsync(CancellationToken cancel)
{
- using (var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, "/api/software/versions"))
+ using (var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, "/api/software/versions", cancel: cancel))
{
if (response.StatusCode == HttpStatusCode.NotFound)
{
@@ -142,9 +142,9 @@ namespace WalletWasabi.WebClients.Wasabi
}
}
- public async Task<(bool backendCompatible, bool clientUpToDate)> CheckUpdatesAsync()
+ public async Task<(bool backendCompatible, bool clientUpToDate)> CheckUpdatesAsync(CancellationToken cancel)
{
- var versions = await GetVersionsAsync();
+ var versions = await GetVersionsAsync(cancel);
var clientUpToDate = Helpers.Constants.ClientVersion >= versions.ClientVersion; // If the client version locally is greater or equal to the backend's reported client version, then good.
var backendCompatible = int.Parse(Helpers.Constants.BackendMajorVersion) == versions.BackendMajorVersion; // If the backend major and the client major equals, then our softwares are compatible.

[skip ci] Improve wallet shutdown speed when internet is off