Optimize algo
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -261,9 +261,12 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
IEnumerable<SmartCoin> best = coinGroups.FirstOrDefault();
+ if (best != default)
+ {
var bestSet = best.ToHashSet();
- if (best != default)
+ // -- OPPORTUNISTIC CONSOLIDATION --
+ if (bestSet.Count < maximumInputCountPerPeer) // Ensure limits.
{
// Generating toxic change leads to mass merging so it's better to merge sooner in coinjoin than the user do it himself in a non-CJ.
// The best selection's anonset should not be lowered by this merge.
@@ -281,17 +284,10 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
&& (bestSum + x.Amount) > amountNeeded) // Sanity check that the amount added don't ruin the registration.
.OrderBy(x => x.Amount); // Choose the smallest ones.
- var bestCoinsToAdd = Enumerable.Empty<SmartCoin>();
if (coinsThoseCanBeConsolidated.Count() > 1) // Because the last one change should not be circulating, ruining privacy.
{
- bestCoinsToAdd = coinsThoseCanBeConsolidated.Take(1);
- }
-
- foreach (SmartCoin coin in bestCoinsToAdd)
- {
- if (bestSet.Count < maximumInputCountPerPeer) // Ensure limits.
- {
- bestSet.Add(coin);
+ var bestCoinToAdd = coinsThoseCanBeConsolidated.First();
+ bestSet.Add(bestCoinToAdd);
}
}
}

Optimize algo