Give priority to coinjoin responses over mempool cleanup
MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -226,6 +226,23 @@ namespace WalletWasabi.Services
}
NewFilterProcessed?.Invoke(this, filterModel);
+ // If Synchronizer is null then go try cleanup mempool (it won't succeed.)
+ // If requests are blocked, delay mempool cleanup, because coinjoin answers are always priority.
+ while (Synchronizer != null && Synchronizer.AreRequestsBlocked())
+ {
+ await Task.Delay(100);
+ }
+
+ await TryCleanupMempoolAsync();
+ }
+ catch (Exception ex)
+ {
+ Logger.LogWarning<WalletService>(ex);
+ }
+ }
+
+ private async Task TryCleanupMempoolAsync()
+ {
// Try perform mempool cleanup based on connected nodes' mempools.
if (Synchronizer != null && Synchronizer.GetFiltersLeft() == 0)
{
@@ -236,11 +253,6 @@ namespace WalletWasabi.Services
}
}
}
- catch (Exception ex)
- {
- Logger.LogWarning<WalletService>(ex);
- }
- }
public async Task InitializeAsync(CancellationToken cancel)
{

MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -132,6 +132,8 @@ namespace WalletWasabi.Services
public TimeSpan MaxRequestIntervalForMixing { get; set; }
private long _blockRequests; // There are priority requests in queue.
+ public bool AreRequestsBlocked() => Interlocked.Read(ref _blockRequests) == 1;
+
public void BlockRequests() => Interlocked.Exchange(ref _blockRequests, 1);
public void EnableRequests() => Interlocked.Exchange(ref _blockRequests, 0);
@@ -261,7 +263,7 @@ namespace WalletWasabi.Services
return;
}
- while (Interlocked.Read(ref _blockRequests) == 1)
+ while (AreRequestsBlocked())
{
await Task.Delay(3000, Cancel.Token);
}
@@ -549,6 +551,8 @@ namespace WalletWasabi.Services
Cancel?.Dispose();
WasabiClient?.Dispose();
+
+ EnableRequests(); // Enable requests (it's possible something is being blocked outside the class by AreRequestsBlocked.
}
_disposedValue = true;

Give priority to coinjoin responses over mempool cleanup