WasabiSynchronizer: Remove request blocking as that is no longer used in WW2
MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -38,9 +38,6 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
/// </summary>
private long _running;
- private long _blockRequests; // There are priority requests in queue.
-
- /// <param name="httpClientFactory">The class takes ownership of the instance.</param>
public WasabiSynchronizer(BitcoinStore bitcoinStore, HttpClientFactory httpClientFactory)
{
LastResponse = null;
@@ -62,15 +59,10 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
public event EventHandler<AllFeeEstimate>? AllFeeEstimateArrived;
public SynchronizeResponse? LastResponse { get; private set; }
-
- /// <summary><see cref="WasabiSynchronizer"/> is responsible for disposing of this object.</summary>
public HttpClientFactory HttpClientFactory { get; }
-
public WasabiClient WasabiClient { get; }
- /// <summary>
- /// Gets the Bitcoin price in USD.
- /// </summary>
+ /// <summary>Gets the Bitcoin price in USD.</summary>
public decimal UsdExchangeRate
{
get => _usdExchangeRate;
@@ -105,21 +97,13 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
public bool IsRunning => Interlocked.Read(ref _running) == StateRunning;
- /// <summary>
- /// Cancellation token source for stopping <see cref="WasabiSynchronizer"/>.
- /// </summary>
+ /// <summary>Cancellation token source for stopping <see cref="WasabiSynchronizer"/>.</summary>
private CancellationTokenSource StopCts { get; }
public AllFeeEstimate? LastAllFeeEstimate => LastResponse?.AllFeeEstimate;
public bool InError => BackendStatus != BackendStatus.Connected;
- public bool AreRequestsBlocked() => Interlocked.Read(ref _blockRequests) == 1;
-
- public void BlockRequests() => Interlocked.Exchange(ref _blockRequests, 1);
-
- public void EnableRequests() => Interlocked.Exchange(ref _blockRequests, 0);
-
#endregion EventsPropertiesMembers
#region Initializers
@@ -145,26 +129,16 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
try
{
bool ignoreRequestInterval = false;
- EnableRequests();
+
while (IsRunning)
{
try
{
- while (AreRequestsBlocked())
- {
- await Task.Delay(3000, StopCts.Token).ConfigureAwait(false);
- }
-
SynchronizeResponse response;
- var lastUsedApiVersion = WasabiClient.ApiVersion;
+ ushort lastUsedApiVersion = WasabiClient.ApiVersion;
try
{
- if (!IsRunning)
- {
- return;
- }
-
response = await WasabiClient
.GetSynchronizeAsync(BitcoinStore.SmartHeaderChain.TipHash, maxFiltersToSyncAtInitialization, EstimateSmartFeeMode.Conservative, StopCts.Token)
.ConfigureAwait(false);
@@ -348,8 +322,6 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
StopCts.Dispose();
- EnableRequests(); // Enable requests (it's possible something is being blocked outside the class by AreRequestsBlocked.
-
Logger.LogTrace("<");
}
}

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -6,7 +6,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Backend.Models;
-using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionBuilding;
@@ -336,9 +335,8 @@ public class Wallet : BackgroundService
NewFilterProcessed?.Invoke(this, filterModel);
- do
- {
await Task.Delay(100).ConfigureAwait(false);
+
if (Synchronizer is null || BitcoinStore?.SmartHeaderChain is null)
{
return;
@@ -349,7 +347,6 @@ public class Wallet : BackgroundService
{
return;
}
- } while (Synchronizer.AreRequestsBlocked()); // If requests are blocked, delay mempool cleanup, because coinjoin answers are always priority.
var task = BitcoinStore.MempoolService?.TryPerformMempoolCleanupAsync(Synchronizer.HttpClientFactory);

WasabiSynchronizer: Remove request blocking as that is no longer used in WW2