41 lines
1.5 KiB
Diff
41 lines
1.5 KiB
Diff
# UNDF: UNDF-2026-000000920
|
|
--- a/WalletWasabi/WabiSabi/Client/CoinJoin/Client/CoinJoinCoinSelector.cs
|
|
+++ b/WalletWasabi/WabiSabi/Client/CoinJoin/Client/CoinJoinCoinSelector.cs
|
|
@@ -305,19 +305,20 @@ public class CoinJoinCoinSelector
|
|
private IEnumerable<TCoin> AnonScoreTxSourceBiasedShuffle<TCoin>(TCoin[] coins)
|
|
where TCoin : ISmartCoin
|
|
{
|
|
- var orderedCoins = new List<TCoin>();
|
|
+ var orderedCoins = new List<TCoin>();
|
|
+ var orderedTxIds = new HashSet<uint256>();
|
|
for (int i = 0; i < coins.Length; i++)
|
|
{
|
|
// Order by anonscore first.
|
|
- var remaining = coins.Except(orderedCoins).OrderBy(x => x.AnonymitySet);
|
|
+ var remaining = coins.Except(orderedCoins).OrderBy(x => x.AnonymitySet);
|
|
|
|
// Then manipulate the list so repeating tx sources go to the end.
|
|
var alternating = new List<TCoin>();
|
|
+ var alternatingTxIds = new HashSet<uint256>();
|
|
var skipped = new List<TCoin>();
|
|
foreach (var c in remaining)
|
|
{
|
|
- if (alternating.Any(x => x.TransactionId == c.TransactionId) || orderedCoins.Any(x => x.TransactionId == c.TransactionId))
|
|
+ if (alternatingTxIds.Contains(c.TransactionId) || orderedTxIds.Contains(c.TransactionId))
|
|
{
|
|
skipped.Add(c);
|
|
}
|
|
@@ -325,12 +326,14 @@ public class CoinJoinCoinSelector
|
|
{
|
|
alternating.Add(c);
|
|
+ alternatingTxIds.Add(c.TransactionId);
|
|
}
|
|
}
|
|
alternating.AddRange(skipped);
|
|
|
|
var coin = alternating.BiasedRandomElement(biasPercent: 50, Rnd)!;
|
|
orderedCoins.Add(coin);
|
|
+ orderedTxIds.Add(coin.TransactionId);
|
|
yield return coin;
|
|
}
|
|
}
|