Make client register into the round the coordinator would prefer for load balancing
MODIFY
WalletWasabi/WabiSabi/Client/RoundStateAwaiters/RoundStateAwaiter.cs
WalletWasabi/WabiSabi/Client/RoundStateAwaiters/RoundStateAwaiter.cs
@@ -36,7 +36,7 @@ public record RoundStateAwaiter
public Task<RoundState> Task => TaskCompletionSource.Task;
- public bool IsCompleted(ImmutableDictionary<uint256, RoundState> allRoundStates)
+ public bool IsCompleted(IDictionary<uint256, RoundState> allRoundStates)
{
if (Task.IsCompleted)
{

MODIFY
WalletWasabi/WabiSabi/Client/RoundStateAwaiters/RoundStateUpdater.cs
WalletWasabi/WabiSabi/Client/RoundStateAwaiters/RoundStateUpdater.cs
@@ -20,7 +20,7 @@ public class RoundStateUpdater : PeriodicRunner
}
private IWabiSabiApiRequestHandler ArenaRequestHandler { get; }
- private ImmutableDictionary<uint256, RoundState> RoundStates { get; set; } = ImmutableDictionary.Create<uint256, RoundState>();
+ private IDictionary<uint256, RoundState> RoundStates { get; set; } = new Dictionary<uint256, RoundState>();
public Dictionary<TimeSpan, FeeRate> CoinJoinFeeRateMedians { get; private set; } = new();
private List<RoundStateAwaiter> Awaiters { get; } = new();
@@ -51,7 +51,9 @@ public class RoundStateUpdater : PeriodicRunner
var newRoundStates = statusResponse
.Where(rs => !RoundStates.ContainsKey(rs.Id));
- RoundStates = newRoundStates.Concat(updatedRoundStates).ToImmutableDictionary(x => x.Id, x => x);
+ // Don't use ToImmutable dictionary, because that ruins the original order and makes the server unable to suggest a round preference.
+ RoundStates = newRoundStates.Concat(updatedRoundStates)
+ .ToDictionary(x => x.Id, x => x);
lock (AwaitersLock)
{

Make client register into the round the coordinator would prefer for load balancing