Adding CoinJoinClientState
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -44,8 +44,12 @@ namespace WalletWasabi.WabiSabi.Client
public Kitchen Kitchen { get; }
public KeyManager Keymanager { get; }
private RoundStateUpdater RoundStatusUpdater { get; }
+ public CoinJoinClientState State { get; private set; }
public async Task<bool> StartCoinJoinAsync(IEnumerable<SmartCoin> coins, CancellationToken cancellationToken)
+ {
+ State = CoinJoinClientState.InProgress;
+ try
{
var currentRoundState = await RoundStatusUpdater.CreateRoundAwaiter(roundState => roundState.Phase == Phase.InputRegistration, cancellationToken).ConfigureAwait(false);
@@ -68,6 +72,11 @@ namespace WalletWasabi.WabiSabi.Client
currentRoundState = blameRoundState;
}
}
+ }
+ finally
+ {
+ State = CoinJoinClientState.Idle;
+ }
return false;
}
@@ -77,6 +86,9 @@ namespace WalletWasabi.WabiSabi.Client
/// <returns>Whether or not the round resulted in a successful transaction.</returns>
public async Task<bool> StartRoundAsync(IEnumerable<SmartCoin> smartCoins, RoundState roundState, CancellationToken cancellationToken)
{
+ try
+ {
+ State = CoinJoinClientState.InProgress;
var constructionState = roundState.Assert<ConstructionState>();
var coinCandidates = SelectCoinsForRound(smartCoins, constructionState.Parameters);
@@ -87,7 +99,7 @@ namespace WalletWasabi.WabiSabi.Client
{
throw new InvalidOperationException($"Round ({roundState.Id}): There is no available alices to participate with.");
}
-
+ State = CoinJoinClientState.InCriticalPhase;
// Calculate outputs values
var registeredCoins = registeredAliceClients.Select(x => x.SmartCoin.Coin);
var availableVsize = registeredAliceClients.SelectMany(x => x.IssuedVsizeCredentials).Sum(x => x.Value);
@@ -129,6 +141,11 @@ namespace WalletWasabi.WabiSabi.Client
var finalRoundState = await RoundStatusUpdater.CreateRoundAwaiter(s => s.Id == roundState.Id && s.Phase == Phase.Ended, cancellationToken).ConfigureAwait(false);
return finalRoundState.WasTransactionBroadcast;
}
+ finally
+ {
+ State = CoinJoinClientState.InProgress;
+ }
+ }
private async Task<ImmutableArray<AliceClient>> CreateRegisterAndConfirmCoinsAsync(IEnumerable<SmartCoin> smartCoins, RoundState roundState, CancellationToken cancellationToken)
{

ADD
WalletWasabi/WabiSabi/Client/CoinJoinClientState.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WalletWasabi.WabiSabi.Client
+{
+ public enum CoinJoinClientState
+ {
+ Idle,
+ InProgress,
+ InCriticalPhase
+ }
+}

Adding CoinJoinClientState