Add CoinJoinTrackingDataFactory
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
@@ -56,6 +56,8 @@ public class CoinJoinManager : BackgroundService
Logger.LogInfo("WabiSabi coinjoin client-side functionality is disabled temporarily on mainnet.");
return;
}
+ CoinJoinTrackingDataFactory coinJoinTrackingDataFactory = new(HttpClientFactory, RoundStatusUpdater, stoppingToken);
+
var trackedCoinJoins = new Dictionary<string, CoinJoinTrackingData>();
while (!stoppingToken.IsCancellationRequested)
@@ -76,7 +78,7 @@ public class CoinJoinManager : BackgroundService
continue;
}
- CoinJoinTrackingData coinJoinTrackingData = new(openedWallet, HttpClientFactory, RoundStatusUpdater, coinCandidates, stoppingToken);
+ CoinJoinTrackingData coinJoinTrackingData = coinJoinTrackingDataFactory.CreateCoinJoinTrackingData(openedWallet, coinCandidates);
trackedCoinJoins.Add(openedWallet.WalletName, coinJoinTrackingData);
WalletStatusChanged?.Invoke(this, new WalletStatusChangedEventArgs(openedWallet, IsCoinJoining: true));

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinTrackingData.cs
WalletWasabi/WabiSabi/Client/CoinJoinTrackingData.cs
@@ -3,33 +3,25 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Wallets;
-using WalletWasabi.WebClients.Wasabi;
namespace WalletWasabi.WabiSabi.Client;
-public class CoinJoinTrackingData : IDisposable
+public record CoinJoinTrackingData : IDisposable
{
private bool _disposedValue;
public CoinJoinTrackingData(
Wallet wallet,
- IWasabiHttpClientFactory httpClientFactory,
- RoundStateUpdater roundStatusUpdater,
+ CoinJoinClient coinJoinClient,
+
IEnumerable<SmartCoin> coinCandidates,
CancellationToken cancellationToken)
{
Wallet = wallet;
-
- CoinJoinClient = new CoinJoinClient(
- httpClientFactory,
- new KeyChain(wallet.KeyManager),
- new InternalDestinationProvider(wallet.KeyManager),
- roundStatusUpdater,
- wallet.ServiceConfiguration.MinAnonScoreTarget);
-
- CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
- CoinJoinTask = CoinJoinClient.StartCoinJoinAsync(coinCandidates, CancellationTokenSource.Token);
+ CoinJoinClient = coinJoinClient;
CoinCandidates = coinCandidates;
+ CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
+ CoinJoinTask = coinJoinClient.StartCoinJoinAsync(coinCandidates, CancellationTokenSource.Token);
}
private CoinJoinClient CoinJoinClient { get; }

ADD
WalletWasabi/WabiSabi/Client/CoinJoinTrackingDataFactory.cs
+using System.Collections.Generic;
+using System.Threading;
+using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.Wallets;
+using WalletWasabi.WebClients.Wasabi;
+
+namespace WalletWasabi.WabiSabi.Client;
+
+public class CoinJoinTrackingDataFactory
+{
+ public CoinJoinTrackingDataFactory(
+ IWasabiHttpClientFactory httpClientFactory,
+ RoundStateUpdater roundStatusUpdater,
+ CancellationToken cancellationToken)
+ {
+ HttpClientFactory = httpClientFactory;
+ RoundStatusUpdater = roundStatusUpdater;
+ CancellationToken = cancellationToken;
+ }
+
+ public IWasabiHttpClientFactory HttpClientFactory { get; }
+ public RoundStateUpdater RoundStatusUpdater { get; }
+ public CancellationToken CancellationToken { get; }
+
+ public CoinJoinTrackingData CreateCoinJoinTrackingData(Wallet wallet, IEnumerable<SmartCoin> coinCandidates)
+ {
+ var coinJoinClient = new CoinJoinClient(
+ HttpClientFactory,
+ new KeyChain(wallet.KeyManager),
+ new InternalDestinationProvider(wallet.KeyManager),
+ RoundStatusUpdater,
+ wallet.ServiceConfiguration.MinAnonScoreTarget);
+
+ return new CoinJoinTrackingData(wallet, coinJoinClient, coinCandidates, CancellationToken);
+ }
+}

Add CoinJoinTrackingDataFactory