Skip to content

Commit

Permalink
add batchpayment
Browse files Browse the repository at this point in the history
  • Loading branch information
Whem committed Apr 7, 2024
1 parent 0dc382b commit 842aeec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WalletWasabi.Fluent/Models/Wallets/WalletCoinjoinModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public WalletCoinjoinModel(Wallet wallet, IWalletSettingsModel settings)
{
_wallet = wallet;
_coinJoinManager = Services.HostedServices.Get<CoinJoinManager>();
_outputWallet = settings.OutputWallet;
_outputWallet = settings.OutputWallet ?? wallet;
StatusUpdated =
Observable.FromEventPattern<StatusChangedEventArgs>(_coinJoinManager, nameof(CoinJoinManager.StatusChanged))
.Where(x => x.EventArgs.Wallet == wallet)
Expand Down
11 changes: 11 additions & 0 deletions WalletWasabi/WabiSabi/Client/CoinJoin/Manager/CoinJoinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using WalletWasabi.Logging;
using WalletWasabi.WabiSabi.Backend.Models;
using WalletWasabi.WabiSabi.Client.Banning;
using WalletWasabi.WabiSabi.Client.Batching;
using WalletWasabi.WabiSabi.Client.CoinJoin.Client;
using WalletWasabi.WabiSabi.Client.CoinJoinProgressEvents;
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
Expand Down Expand Up @@ -201,6 +202,16 @@ async Task<IEnumerable<SmartCoin>> SanityChecksAndGetCoinCandidatesFunc()

var coinCandidates = await SelectCandidateCoinsAsync(walletToStart, synchronizerResponse.BestHeight).ConfigureAwait(false);

var result = await walletToStart.GetCoinjoinCoinCandidatesAsync();
var coins = result.Where(x => x.IsPrivate(walletToStart.AnonScoreTarget)).ToArray();

var batchedPayments = new PaymentBatch();

foreach (SmartCoin smartCoin in coins)
{
batchedPayments.AddPayment(startCommand.OutputWallet.DestinationProvider.GetNextDestinations(1, false).FirstOrDefault(), smartCoin.Amount);
}

Check warning on line 214 in WalletWasabi/WabiSabi/Client/CoinJoin/Manager/CoinJoinManager.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

❌ Getting worse: Complex Method

HandleCoinJoinCommandsAsync increases in cyclomatic complexity from 20 to 21, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
// If there are pending payments, ignore already achieved privacy.
if (!walletToStart.BatchedPayments.AreTherePendingPayments)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CoinJoinTrackerFactory
private string CoordinatorIdentifier { get; }
private LiquidityClueProvider LiquidityClueProvider { get; }

public async Task<CoinJoinTracker> CreateAndStartAsync(IWallet wallet, IWallet outputWallet, Func<Task<IEnumerable<SmartCoin>>> coinCandidatesFunc, bool stopWhenAllMixed, bool overridePlebStop)
public async Task<CoinJoinTracker> CreateAndStartAsync(IWallet wallet, IWallet? outputWallet, Func<Task<IEnumerable<SmartCoin>>> coinCandidatesFunc, bool stopWhenAllMixed, bool overridePlebStop)
{
await LiquidityClueProvider.InitLiquidityClueAsync(wallet).ConfigureAwait(false);

Expand Down

0 comments on commit 842aeec

Please sign in to comment.