Change order: first alternate, then send the larger ones to the end
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -621,28 +621,29 @@ public class CoinJoinClient
var biasSuffledPrivateCoins = AnonScoreBiasedShuffle(privateCoins).ToArray();
- // Deprioritize private coins those are too large.
- var smallerPrivateCoins = biasSuffledPrivateCoins.Where(x => x.Amount <= liquidityClue);
- var largerPrivateCoins = biasSuffledPrivateCoins.Where(x => x.Amount > liquidityClue);
-
// Manipulate the list so repeating tx sources get to the end.
- var allowedPrivateCoins = new List<SmartCoin>();
+ var alternatingPrivateCoins = new List<SmartCoin>();
var skipped = new List<SmartCoin>();
- foreach (var c in smallerPrivateCoins.Concat(largerPrivateCoins))
+ foreach (var c in biasSuffledPrivateCoins)
{
- if (allowedPrivateCoins.Any(x => x.TransactionId == c.TransactionId))
+ if (alternatingPrivateCoins.Any(x => x.TransactionId == c.TransactionId))
{
skipped.Add(c);
}
else
{
- allowedPrivateCoins.Add(c);
+ alternatingPrivateCoins.Add(c);
}
}
+ alternatingPrivateCoins.AddRange(skipped);
+
+ // Deprioritize private coins those are too large.
+ var smallerPrivateCoins = alternatingPrivateCoins.Where(x => x.Amount <= liquidityClue);
+ var largerPrivateCoins = alternatingPrivateCoins.Where(x => x.Amount > liquidityClue);
// Let's allow only inputCount - 1 private coins to play.
- allowedPrivateCoins = allowedPrivateCoins.Concat(skipped).Take(inputCount - 1).ToList();
- Logger.LogDebug($"{nameof(allowedPrivateCoins)}: {allowedPrivateCoins.Count} coins, valued at {Money.Satoshis(allowedPrivateCoins.Sum(x => x.Amount)).ToString(false, true)} BTC.");
+ var allowedPrivateCoins = smallerPrivateCoins.Concat(largerPrivateCoins).Take(inputCount - 1).ToArray();
+ Logger.LogDebug($"{nameof(allowedPrivateCoins)}: {allowedPrivateCoins.Length} coins, valued at {Money.Satoshis(allowedPrivateCoins.Sum(x => x.Amount)).ToString(false, true)} BTC.");
var allowedCoins = allowedNonPrivateCoins.Concat(allowedPrivateCoins).ToArray();
Logger.LogDebug($"{nameof(allowedCoins)}: {allowedCoins.Length} coins, valued at {Money.Satoshis(allowedCoins.Sum(x => x.Amount)).ToString(false, true)} BTC.");

Change order: first alternate, then send the larger ones to the end