Add RoundStateAwaiter
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/CoinJoinClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/CoinJoinClientTests.cs
@@ -53,7 +53,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var wabiSabiApi = new WabiSabiController(coordinator);
- using var roundStateUpdater = new RoundStatusUpdater(TimeSpan.FromSeconds(1), wabiSabiApi);
+ using var roundStateUpdater = new RoundStateUpdater(TimeSpan.FromSeconds(1), wabiSabiApi);
await roundStateUpdater.StartAsync(CancellationToken.None);
using CoinJoinClient coinJoinClient = new(wabiSabiApi, new[] { smartCoin.Coin }, kitchen, km, roundStateUpdater);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
@@ -110,7 +110,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Integration
var kitchen = new Kitchen();
kitchen.Cook("");
- using var roundStateUpdater = new RoundStatusUpdater(TimeSpan.FromSeconds(1), apiClient);
+ using var roundStateUpdater = new RoundStateUpdater(TimeSpan.FromSeconds(1), apiClient);
await roundStateUpdater.StartAsync(CancellationToken.None);
using var coinJoinClient = new CoinJoinClient(apiClient, coins, kitchen, keyManager, roundStateUpdater);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Models/RoundStatusUpdaterTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Models/RoundStatusUpdaterTests.cs
@@ -29,7 +29,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Models
mockApiClient.Setup(apiClient => apiClient.GetStatusAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(() => roundStates.ToArray());
- using RoundStatusUpdater roundStatusUpdater = new(TimeSpan.FromSeconds(1), mockApiClient.Object);
+ using RoundStateUpdater roundStatusUpdater = new(TimeSpan.FromSeconds(1), mockApiClient.Object);
await roundStatusUpdater.StartAsync(cancellationTokenSource.Token);
var waitFirst = await roundStatusUpdater.CreateRoundAwaiter(rs => rs.Phase == Phase.InputRegistration, cancellationToken);

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -27,7 +27,7 @@ namespace WalletWasabi.WabiSabi.Client
IEnumerable<Coin> coins,
Kitchen kitchen,
KeyManager keymanager,
- RoundStatusUpdater roundStatusUpdater)
+ RoundStateUpdater roundStatusUpdater)
{
ArenaRequestHandler = arenaRequestHandler;
Kitchen = kitchen;
@@ -46,7 +46,7 @@ namespace WalletWasabi.WabiSabi.Client
public IWabiSabiApiRequestHandler ArenaRequestHandler { get; }
public Kitchen Kitchen { get; }
public KeyManager Keymanager { get; }
- private RoundStatusUpdater RoundStatusUpdater { get; }
+ private RoundStateUpdater RoundStatusUpdater { get; }
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{

ADD
WalletWasabi/WabiSabi/Client/RoundStateAwaiter.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.WabiSabi.Models;
+
+namespace WalletWasabi.WabiSabi.Client
+{
+ public record RoundStateAwaiter(TaskCompletionSource<RoundState> Task, Predicate<RoundState> Predicate)
+ {
+ }
+}

RENAME
WalletWasabi/WabiSabi/Client/RoundStatusUpdater.cs
WalletWasabi/WabiSabi/Client/RoundStateUpdater.cs
@@ -10,9 +10,9 @@ using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Client
{
- public class RoundStatusUpdater : PeriodicRunner
+ public class RoundStateUpdater : PeriodicRunner
{
- public RoundStatusUpdater(TimeSpan requestInterval, IWabiSabiApiRequestHandler arenaRequestHandler) : base(requestInterval)
+ public RoundStateUpdater(TimeSpan requestInterval, IWabiSabiApiRequestHandler arenaRequestHandler) : base(requestInterval)
{
ArenaRequestHandler = arenaRequestHandler;
}
@@ -20,7 +20,7 @@ namespace WalletWasabi.WabiSabi.Client
private IWabiSabiApiRequestHandler ArenaRequestHandler { get; }
private Dictionary<uint256, RoundState> RoundStates { get; set; } = new();
- private Dictionary<uint256, List<(TaskCompletionSource<RoundState> Task, Predicate<RoundState> Predicate)>> Awaiters { get; } = new();
+ private Dictionary<uint256, List<RoundStateAwaiter>> Awaiters { get; } = new();
private object AwaitersLock { get; } = new();
protected override async Task ActionAsync(CancellationToken cancellationToken)
@@ -77,7 +77,7 @@ namespace WalletWasabi.WabiSabi.Client
}
}
- private static void HandleTasks(List<(TaskCompletionSource<RoundState> Task, Predicate<RoundState> Predicate)> taskAndPredicateList, RoundState roundState)
+ private static void HandleTasks(List<RoundStateAwaiter> taskAndPredicateList, RoundState roundState)
{
foreach (var taskAndPredicate in taskAndPredicateList.Where(taskAndPredicate => taskAndPredicate.Predicate(roundState)).ToArray())
{
@@ -95,11 +95,11 @@ namespace WalletWasabi.WabiSabi.Client
{
if (!Awaiters.ContainsKey(roundId))
{
- Awaiters.Add(roundId, new List<(TaskCompletionSource<RoundState>, Predicate<RoundState>)>());
+ Awaiters.Add(roundId, new List<RoundStateAwaiter>());
}
var predicateList = Awaiters[roundId];
- var taskAndPredicate = (tcs, predicate);
+ var taskAndPredicate = new RoundStateAwaiter(tcs, predicate);
predicateList.Add(taskAndPredicate);
cancellationToken.Register(() =>

Add RoundStateAwaiter