Replace Rounds dictionary by HashSet
MODIFY
WalletWasabi.Backend/Controllers/WabiSabiController.cs
WalletWasabi.Backend/Controllers/WabiSabiController.cs
@@ -65,7 +65,7 @@ namespace WalletWasabi.Backend.Controllers
[HttpGet("status")]
public Task<RoundState[]> GetStatusAsync(CancellationToken cancellableToken)
{
- return Task.FromResult(RequestHandler.Arena.Rounds.Values.Select(x => RoundState.FromRound(x)).ToArray());
+ return Task.FromResult(RequestHandler.Arena.Rounds.Select(x => RoundState.FromRound(x)).ToArray());
}
}
}

MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -98,7 +98,7 @@ namespace WalletWasabi.Tests.Helpers
Arena arena = new(TimeSpan.FromHours(1), Network.Main, cfg, mockRpc.Object, new Prison());
foreach (var round in rounds)
{
- arena.Rounds.Add(round.Id, round);
+ arena.Rounds.Add(round);
}
await arena.StartAsync(CancellationToken.None).ConfigureAwait(false);
return arena;
@@ -121,7 +121,7 @@ namespace WalletWasabi.Tests.Helpers
public static ArenaClient CreateArenaClient(Arena arena)
{
- var roundState = RoundState.FromRound(arena.Rounds.First().Value);
+ var roundState = RoundState.FromRound(arena.Rounds.First());
var random = new InsecureRandom();
return new ArenaClient(
roundState.CreateAmountCredentialClient(new ZeroCredentialPool(), random),

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepConnectionConfirmationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepConnectionConfirmationTests.cs
@@ -124,7 +124,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
+ Assert.DoesNotContain(round, arena.Rounds);
Assert.Equal(3, arena.Prison.CountInmates().noted);
Assert.Equal(0, arena.Prison.CountInmates().banned);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepInputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepInputRegistrationTests.cs
@@ -129,7 +129,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
round.Alices.Add(WabiSabiFactory.CreateAlice());
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
Assert.Equal(Phase.InputRegistration, round.Phase);
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
+ Assert.DoesNotContain(round, arena.Rounds);
await arena.StopAsync(CancellationToken.None);
}
@@ -158,7 +158,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, blameRound);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
Assert.Equal(Phase.InputRegistration, blameRound.Phase);
- Assert.DoesNotContain(blameRound.Id, arena.Rounds.Keys);
+ Assert.DoesNotContain(blameRound, arena.Rounds);
await arena.StopAsync(CancellationToken.None);
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
@@ -198,9 +198,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
{
// Create the round.
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
-
- var round = Assert.Single(arena.Rounds).Value;
var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
+ var round = Assert.Single(arena.Rounds);
// Register Alices.
var aliceClient1 = new AliceClient(round.Id, arenaClient, coin1, round.FeeRate, key1.GetBitcoinSecret(round.Network));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
@@ -74,7 +74,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
await aliceClient1.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await aliceClient2.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
+ Assert.DoesNotContain(round, arena.Rounds);
Assert.Empty(arena.Prison.GetInmates());
await arena.StopAsync(CancellationToken.None);
@@ -109,7 +109,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
await aliceClient1.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await aliceClient2.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
+ Assert.DoesNotContain(round, arena.Rounds);
// There should be no inmate, because we aren't punishing spenders with banning
// as there's no reason to ban already spent UTXOs,
@@ -147,8 +147,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var signedCoinJoin = round.Assert<SigningState>().CreateTransaction();
await aliceClient1.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
- Assert.Empty(arena.Rounds.Where(x => x.Value.IsBlameRound));
+ Assert.DoesNotContain(round, arena.Rounds);
+ Assert.Empty(arena.Rounds.Where(x => x.IsBlameRound));
Assert.Contains(aliceClient2.Coin.Outpoint, arena.Prison.GetInmates().Select(x => x.Utxo));
await arena.StopAsync(CancellationToken.None);
@@ -189,13 +189,12 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
await aliceClient1.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await aliceClient2.SignTransactionAsync(signedCoinJoin, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
-
- Assert.DoesNotContain(round.Id, arena.Rounds.Keys);
- Assert.Single(arena.Rounds.Where(x => x.Value.IsBlameRound));
+ Assert.DoesNotContain(round, arena.Rounds);
+ Assert.Single(arena.Rounds.Where(x => x.IsBlameRound));
var badOutpoint = alice3.Coin.Outpoint;
Assert.Contains(badOutpoint, arena.Prison.GetInmates().Select(x => x.Utxo));
- var blameRound = arena.Rounds.Single(x => x.Value.IsBlameRound).Value;
+ var blameRound = arena.Rounds.Single(x => x.IsBlameRound);
Assert.True(blameRound.IsBlameRound);
Assert.NotNull(blameRound.BlameOf);
Assert.Equal(round.Id, blameRound.BlameOf?.Id);
@@ -214,7 +213,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
// Create the round.
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- var round = Assert.Single(arena.Rounds).Value;
+ var round = Assert.Single(arena.Rounds);
var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
// Register Alices.

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/ConfirmConnectionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/ConfirmConnectionTests.cs
@@ -94,7 +94,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
var preDeadline = alice.Deadline;
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = arena.Rounds.First().Value;
+ var round = arena.Rounds.First();
round.Alices.Add(alice);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
@@ -44,7 +44,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
WabiSabiConfig cfg = new();
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = arena.Rounds.First().Value;
+ var round = arena.Rounds.First();
using Key key = new();
var req = WabiSabiFactory.CreateInputRegistrationRequest(round, key: key);
await using ArenaRequestHandler handler = new(cfg, new(), arena, WabiSabiFactory.CreatePreconfiguredRpcClient().Object);
@@ -121,7 +121,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- arena.Rounds.Add(round.Id, round);
+ arena.Rounds.Add(round);
var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
var ex = await Assert.ThrowsAsync<WabiSabiProtocolException>(
@@ -141,7 +141,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, WabiSabiFactory.CreatePreconfiguredRpcClient(coin));
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
- var round = arena.Rounds.First().Value;
+
+ var round = arena.Rounds.First();
cfg.StandardInputRegistrationTimeout = TimeSpan.Zero;

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterOutputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterOutputTests.cs
@@ -150,7 +150,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg);
await using ArenaRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = arena.Rounds.First().Value;
+ var round = arena.Rounds.First();
round.Alices.Add(WabiSabiFactory.CreateAlice());
foreach (Phase phase in Enum.GetValues(typeof(Phase)))

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RemoveInputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RemoveInputTests.cs
@@ -66,7 +66,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
WabiSabiConfig cfg = new();
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = arena.Rounds.First().Value;
+ var round = arena.Rounds.First();
var req = new InputsRemovalRequest(round.Id, BitcoinFactory.CreateUint256());
foreach (Phase phase in Enum.GetValues(typeof(Phase)))

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/SignTransactionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/SignTransactionTests.cs
@@ -56,7 +56,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
WabiSabiConfig cfg = new();
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = arena.Rounds.First().Value;
+ var round = arena.Rounds.First();
var req = new TransactionSignaturesRequest(round.Id, null!);
foreach (Phase phase in Enum.GetValues(typeof(Phase)))

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RoundCreationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RoundCreationTests.cs
@@ -53,7 +53,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
Assert.Empty(arena.Rounds);
await arena.StartAsync(CancellationToken.None).ConfigureAwait(false);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = Assert.Single(arena.Rounds).Value;
+ var round = Assert.Single(arena.Rounds);
round.SetPhase(Phase.ConnectionConfirmation);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
@@ -78,16 +78,16 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
Assert.Empty(arena.Rounds);
await arena.StartAsync(CancellationToken.None).ConfigureAwait(false);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
- var round = Assert.Single(arena.Rounds).Value;
+ var round = Assert.Single(arena.Rounds);
round.SetPhase(Phase.ConnectionConfirmation);
round.Alices.Add(WabiSabiFactory.CreateAlice());
Round blameRound = WabiSabiFactory.CreateBlameRound(round, cfg);
Assert.Equal(Phase.InputRegistration, blameRound.Phase);
- arena.Rounds.Add(blameRound.Id, blameRound);
+ arena.Rounds.Add(blameRound);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21)).ConfigureAwait(false);
Assert.Equal(3, arena.Rounds.Count);
- Assert.Equal(2, arena.Rounds.Where(x => x.Value.Phase == Phase.InputRegistration).Count());
+ Assert.Equal(2, arena.Rounds.Where(x => x.Phase == Phase.InputRegistration).Count());
await arena.StopAsync(CancellationToken.None);
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -47,7 +47,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
roundState.CreateAmountCredentialClient(amountCredentialPool, insecureRandom),
roundState.CreateVsizeCredentialClient(vsizeCredentialPool, insecureRandom),
wabiSabiApi);
- Assert.Equal(Phase.InputRegistration, arena.Rounds.First().Value.Phase);
+ Assert.Equal(Phase.InputRegistration, arena.Rounds.First().Phase);
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);
@@ -59,7 +59,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));
await confirmationTask;
- Assert.Equal(Phase.ConnectionConfirmation, arena.Rounds.First().Value.Phase);
+ Assert.Equal(Phase.ConnectionConfirmation, arena.Rounds.First().Phase);
}
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
@@ -54,9 +54,9 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
OwnershipProof ownershipProof,
ZeroCredentialsRequest zeroAmountCredentialRequests,
ZeroCredentialsRequest zeroVsizeCredentialRequests,
- IDictionary<uint256, Round> rounds)
+ HashSet<Round> rounds)
{
- if (!rounds.TryGetValue(roundId, out var round))
+ if (rounds.FirstOrDefault(x => x.Id == roundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound);
}
@@ -115,9 +115,9 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
commitVsizeCredentialResponse.Commit());
}
- private static void RemoveDuplicateAlices(IDictionary<uint256, Round> roundsWithId, Alice alice)
+ private static void RemoveDuplicateAlices(HashSet<Round> roundsWithId, Alice alice)
{
- var rounds = roundsWithId.Values;
+ var rounds = roundsWithId;
if (rounds.Any(x => x.Phase != Phase.InputRegistration))
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.AliceAlreadyRegistered);

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -28,7 +28,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
Random = new SecureRandom();
}
- public Dictionary<uint256, Round> Rounds { get; } = new();
+ public HashSet<Round> Rounds { get; } = new();
private AsyncLock AsyncLock { get; } = new();
public Network Network { get; }
public WabiSabiConfig Config { get; }
@@ -60,14 +60,14 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private void StepInputRegistrationPhase()
{
- foreach (var round in Rounds.Values.Where(x =>
+ foreach (var round in Rounds.Where(x =>
x.Phase == Phase.InputRegistration
&& x.IsInputRegistrationEnded(Config.MaxInputCountByRound, Config.GetInputRegistrationTimeout(x)))
.ToArray())
{
if (round.InputCount < Config.MinInputCountByRound)
{
- Rounds.Remove(round.Id);
+ Rounds.Remove(round);
round.LogInfo($"Not enough inputs ({round.InputCount}) in {nameof(Phase.InputRegistration)} phase.");
}
else
@@ -79,7 +79,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private void StepConnectionConfirmationPhase()
{
- foreach (var round in Rounds.Values.Where(x => x.Phase == Phase.ConnectionConfirmation).ToArray())
+ foreach (var round in Rounds.Where(x => x.Phase == Phase.ConnectionConfirmation).ToArray())
{
if (round.Alices.All(x => x.ConfirmedConnection))
{
@@ -97,7 +97,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
if (round.InputCount < Config.MinInputCountByRound)
{
- Rounds.Remove(round.Id);
+ Rounds.Remove(round);
round.LogInfo($"Not enough inputs ({round.InputCount}) in {nameof(Phase.ConnectionConfirmation)} phase.");
}
else
@@ -110,7 +110,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private void StepOutputRegistrationPhase()
{
- foreach (var round in Rounds.Values.Where(x => x.Phase == Phase.OutputRegistration).ToArray())
+ foreach (var round in Rounds.Where(x => x.Phase == Phase.OutputRegistration).ToArray())
{
long aliceSum = round.Alices.Sum(x => x.CalculateRemainingAmountCredentials(round.FeeRate));
long bobSum = round.Bobs.Sum(x => x.CredentialAmount);
@@ -140,7 +140,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private async Task StepTransactionSigningPhaseAsync()
{
- foreach (var round in Rounds.Values.Where(x => x.Phase == Phase.TransactionSigning).ToArray())
+ foreach (var round in Rounds.Where(x => x.Phase == Phase.TransactionSigning).ToArray())
{
var state = round.Assert<SigningState>();
@@ -204,7 +204,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
}
round.Alices.RemoveAll(x => alicesWhoDidntSign.Contains(x));
- Rounds.Remove(round.Id);
+ Rounds.Remove(round);
if (round.InputCount >= Config.MinInputCountByRound)
{
@@ -217,24 +217,24 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
var feeRate = (await Rpc.EstimateSmartFeeAsync((int)Config.ConfirmationTarget, EstimateSmartFeeMode.Conservative, simulateIfRegTest: true).ConfigureAwait(false)).FeeRate;
RoundParameters parameters = new(Config, Network, Random, feeRate, blameOf: round);
Round blameRound = new(parameters);
- Rounds.Add(blameRound.Id, blameRound);
+ Rounds.Add(blameRound);
}
private async Task CreateRoundsAsync()
{
- if (!Rounds.Values.Any(x => !x.IsBlameRound && x.Phase == Phase.InputRegistration))
+ if (!Rounds.Any(x => !x.IsBlameRound && x.Phase == Phase.InputRegistration))
{
var feeRate = (await Rpc.EstimateSmartFeeAsync((int)Config.ConfirmationTarget, EstimateSmartFeeMode.Conservative, simulateIfRegTest: true).ConfigureAwait(false)).FeeRate;
RoundParameters roundParams = new(Config, Network, Random, feeRate);
Round r = new(roundParams);
- Rounds.Add(r.Id, r);
+ Rounds.Add(r);
}
}
private void TimeoutAlices()
{
- foreach (var round in Rounds.Values.Where(x => !x.IsInputRegistrationEnded(Config.MaxInputCountByRound, Config.GetInputRegistrationTimeout(x))).ToArray())
+ foreach (var round in Rounds.Where(x => !x.IsInputRegistrationEnded(Config.MaxInputCountByRound, Config.GetInputRegistrationTimeout(x))).ToArray())
{
var removedAliceCount = round.Alices.RemoveAll(x => x.Deadline < DateTimeOffset.UtcNow);
if (removedAliceCount > 0)
@@ -264,7 +264,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
using (await AsyncLock.LockAsync().ConfigureAwait(false))
{
- if (!Rounds.TryGetValue(request.RoundId, out var round))
+ if (Rounds.FirstOrDefault(x => x.Id == request.RoundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound, $"Round ({request.RoundId}) not found.");
}
@@ -280,7 +280,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
using (await AsyncLock.LockAsync().ConfigureAwait(false))
{
- if (!Rounds.TryGetValue(request.RoundId, out var round))
+ if (Rounds.FirstOrDefault(x => x.Id == request.RoundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound, $"Round ({request.RoundId}) not found.");
}
@@ -344,7 +344,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
using (await AsyncLock.LockAsync().ConfigureAwait(false))
{
- if (!Rounds.TryGetValue(request.RoundId, out var round))
+ if (Rounds.FirstOrDefault(x => x.Id == request.RoundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound, $"Round ({request.RoundId}) not found.");
}
@@ -388,7 +388,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
using (await AsyncLock.LockAsync().ConfigureAwait(false))
{
- if (!Rounds.TryGetValue(request.RoundId, out var round))
+ if (Rounds.FirstOrDefault(x => x.Id == request.RoundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound, $"Round ({request.RoundId}) not found.");
}
@@ -413,7 +413,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
using (await AsyncLock.LockAsync().ConfigureAwait(false))
{
- if (!Rounds.TryGetValue(request.RoundId, out var round))
+ if (Rounds.FirstOrDefault(x => x.Id == request.RoundId) is not Round round)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound, $"Round ({request.RoundId}) not found.");
}

Replace Rounds dictionary by HashSet