WasabiSynchronizer: Cancelling + logging.
MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -118,6 +118,8 @@ namespace WalletWasabi.Services
public void Start(TimeSpan requestInterval, TimeSpan feeQueryRequestInterval, int maxFiltersToSyncAtInitialization)
{
+ Logger.LogTrace($"> {nameof(requestInterval)}={requestInterval}, {nameof(feeQueryRequestInterval)}={feeQueryRequestInterval}, {nameof(maxFiltersToSyncAtInitialization)}={maxFiltersToSyncAtInitialization}");
+
Guard.NotNull(nameof(requestInterval), requestInterval);
Guard.MinimumAndNotNull(nameof(feeQueryRequestInterval), feeQueryRequestInterval, requestInterval);
Guard.MinimumAndNotNull(nameof(maxFiltersToSyncAtInitialization), maxFiltersToSyncAtInitialization, 0);
@@ -131,6 +133,8 @@ namespace WalletWasabi.Services
Task.Run(async () =>
{
+ Logger.LogTrace("> Starting Wasabi synchronizer thread starts.");
+
try
{
DateTimeOffset lastFeeQueried = DateTimeOffset.UtcNow - feeQueryRequestInterval;
@@ -300,6 +304,10 @@ namespace WalletWasabi.Services
LastResponse = response;
ResponseArrived?.Invoke(this, response);
}
+ catch (OperationCanceledException)
+ {
+ Logger.LogInfo("Wasabi Synchronizer execution was canceled.");
+ }
catch (ConnectionException ex)
{
Logger.LogError(ex);
@@ -312,7 +320,7 @@ namespace WalletWasabi.Services
Logger.LogTrace(ex2);
}
}
- catch (Exception ex) when (ex is OperationCanceledException || ex is TaskCanceledException || ex is TimeoutException)
+ catch (TimeoutException ex)
{
Logger.LogTrace(ex);
}
@@ -341,7 +349,11 @@ namespace WalletWasabi.Services
{
Interlocked.CompareExchange(ref _running, 3, 2); // If IsStopping, make it stopped.
}
+
+ Logger.LogTrace("< Wasabi synchronizer thread ends.");
});
+
+ Logger.LogTrace("<");
}
#endregion Initializers
@@ -377,6 +389,8 @@ namespace WalletWasabi.Services
public async Task StopAsync()
{
+ Logger.LogTrace(">");
+
Interlocked.CompareExchange(ref _running, 2, 1); // If running, make it stopping.
Cancel?.Cancel();
while (Interlocked.CompareExchange(ref _running, 3, 0) == 2)
@@ -390,6 +404,8 @@ namespace WalletWasabi.Services
WasabiClient = null;
EnableRequests(); // Enable requests (it's possible something is being blocked outside the class by AreRequestsBlocked.
+
+ Logger.LogTrace("<");
}
}
}

MODIFY
WalletWasabi/Tor/Socks5/TorSocks5Client.cs
WalletWasabi/Tor/Socks5/TorSocks5Client.cs
@@ -62,8 +62,7 @@ namespace WalletWasabi.Tor.Socks5
}
catch (Exception ex) when (IsConnectionRefused(ex))
{
- throw new ConnectionException(
- $"Could not connect to Tor SOCKSPort at {host}:{port}. Is Tor running?", ex);
+ throw new ConnectionException($"Could not connect to Tor SOCKSPort at {host}:{port}. Is Tor running?", ex);
}
Stream = TcpClient.GetStream();

WasabiSynchronizer: Cancelling + logging.