Get the status from RoundStates instead of Rounds
MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
@@ -377,18 +377,16 @@ public partial class Arena : IWabiSabiApiRequestHandler
return new Coin(input, txOutResponse.TxOut);
}
- public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
+ public Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
{
- using (await AsyncLock.LockAsync(cancellationToken).ConfigureAwait(false))
- {
- var roundStates = Rounds.Select(x =>
+ var requestCheckPointDictionary = request.RoundCheckpoints.ToDictionary(r => r.RoundId, r => r);
+ var responseRoundStates = RoundStates.Select(x =>
{
- var checkPoint = request.RoundCheckpoints.FirstOrDefault(y => y.RoundId == x.Id);
- return RoundState.FromRound(x, checkPoint == default ? 0 : checkPoint.StateId);
+ requestCheckPointDictionary.TryGetValue(x.Id, out RoundStateCheckpoint? checkPoint);
+ return x.GetSubState(checkPoint == default ? 0 : checkPoint.StateId);
}).ToArray();
- return new RoundStateResponse(roundStates, Array.Empty<CoinJoinFeeRateMedian>());
- }
+ return Task.FromResult(new RoundStateResponse(responseRoundStates, Array.Empty<CoinJoinFeeRateMedian>()));
}
private Round GetRound(uint256 roundId) =>

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -14,6 +14,8 @@ using WalletWasabi.WabiSabi.Backend.Models;
using WalletWasabi.WabiSabi.Models.MultipartyTransaction;
using WalletWasabi.WabiSabi.Backend.Rounds.CoinJoinStorage;
using WalletWasabi.WabiSabi.Backend.Statistics;
+using System.Collections.Immutable;
+using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Backend.Rounds;
@@ -40,6 +42,7 @@ public partial class Arena : PeriodicRunner
}
public HashSet<Round> Rounds { get; } = new();
+ private ImmutableArray<RoundState> RoundStates { get; set; } = ImmutableArray.Create<RoundState>();
private AsyncLock AsyncLock { get; } = new();
private Network Network { get; }
private WabiSabiConfig Config { get; }
@@ -74,6 +77,8 @@ public partial class Arena : PeriodicRunner
// Ensure there's at least one non-blame round in input registration.
await CreateRoundsAsync(cancel).ConfigureAwait(false);
+
+ RoundStates = Rounds.Select(r => RoundState.FromRound(r, stateId: 0)).ToImmutableArray();
}
}

MODIFY
WalletWasabi/WabiSabi/Models/RoundState.cs
WalletWasabi/WabiSabi/Models/RoundState.cs
@@ -26,7 +26,7 @@ public record RoundState(
long MaxSuggestedAmount,
MultipartyTransactionState CoinjoinState)
{
- private uint256 _id;
+ private uint256? _id;
public uint256 Id => _id ??= CalculateHash();
@@ -53,6 +53,27 @@ public record RoundState(
round.CoinjoinState.GetStateFrom(stateId)
);
+ public RoundState GetSubState(int skipFromBaseState) =>
+ new(
+ BlameOf,
+ AmountCredentialIssuerParameters,
+ VsizeCredentialIssuerParameters,
+ FeeRate,
+ CoordinationFeeRate,
+ Phase,
+ WasTransactionBroadcast,
+ InputRegistrationStart,
+ InputRegistrationTimeout,
+ ConnectionConfirmationTimeout,
+ OutputRegistrationTimeout,
+ TransactionSigningTimeout,
+ MaxAmountCredentialValue,
+ MaxVsizeCredentialValue,
+ MaxVsizeAllocationPerAlice,
+ MaxSuggestedAmount,
+ CoinjoinState.GetStateFrom(skipFromBaseState)
+ );
+
public TState Assert<TState>() where TState : MultipartyTransactionState =>
CoinjoinState switch
{

Get the status from RoundStates instead of Rounds