extract to local methods
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
@@ -136,22 +136,18 @@ public class CoinJoinManager : BackgroundService
{
var coinJoinTrackerFactory = new CoinJoinTrackerFactory(HttpClientFactory, RoundStatusUpdater, stoppingToken);
- while (!stoppingToken.IsCancellationRequested)
- {
- var command = await CommandChannel.Reader.ReadAsync(stoppingToken).ConfigureAwait(false);
- switch (command)
+ void StartCoinJoinCommand(StartCoinJoinCommand startCommand)
{
- case StartCoinJoinCommand startCommand:
var walletToStart = startCommand.Wallet;
if (trackedCoinJoins.ContainsKey(walletToStart.WalletName))
{
- continue;
+ return;
}
var coinCandidates = SelectCandidateCoins(walletToStart).ToArray();
if (coinCandidates.Length == 0)
{
NotifyCoinJoinStartError(walletToStart, CoinjoinError.NoCoinsToMix);
- continue;
+ return;
}
var coinJoinTracker = coinJoinTrackerFactory.CreateAndStart(walletToStart, coinCandidates, startCommand.RestartAutomatically);
@@ -159,14 +155,28 @@ public class CoinJoinManager : BackgroundService
trackedCoinJoins.AddOrUpdate(walletToStart.WalletName, _ => coinJoinTracker, (_, cjt) => cjt);
var registrationTimeout = TimeSpan.MaxValue;
NotifyCoinJoinStarted(walletToStart, registrationTimeout);
- break;
+ }
- case StopCoinJoinCommand stopCommand:
+ void StopCoinJoinCommand(StopCoinJoinCommand stopCommand)
+ {
var walletToStop = stopCommand.Wallet;
if (trackedCoinJoins.TryGetValue(walletToStop.WalletName, out var coinJoinTrackerToStop))
{
coinJoinTrackerToStop.Cancel();
}
+ }
+
+ while (!stoppingToken.IsCancellationRequested)
+ {
+ var command = await CommandChannel.Reader.ReadAsync(stoppingToken).ConfigureAwait(false);
+ switch (command)
+ {
+ case StartCoinJoinCommand startCommand:
+ StartCoinJoinCommand(startCommand);
+ break;
+
+ case StopCoinJoinCommand stopCommand:
+ StopCoinJoinCommand(stopCommand);
break;
}
}

extract to local methods