Optimize backend code redundancy
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -465,23 +465,14 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
case CcjRoundPhase.Signing:
{
- var alicesToBan = new List<Alice>();
+ Alice[] alicesToBan = GetAlicesByNot(AliceState.SignedCoinJoin, syncLock: true).ToArray();
- using (await RoundSynchronizerLock.LockAsync())
- {
- foreach (Alice alice in Alices)
- {
- if (alice.State != AliceState.SignedCoinJoin)
- {
- alicesToBan.Add(alice);
- }
- }
- }
if (alicesToBan.Any())
{
await UtxoReferee.BanUtxosAsync(1, DateTimeOffset.UtcNow, forceNoted: false, RoundId, alicesToBan.SelectMany(x => x.Inputs.Select(y => y.Outpoint)).ToArray());
}
- Abort(nameof(CcjRound), $"{alicesToBan.Count} Alices did not sign.");
+
+ Abort(nameof(CcjRound), $"{alicesToBan.Length} Alices did not sign.");
}
break;

MODIFY
WalletWasabi/Services/CcjCoordinator.cs
WalletWasabi/Services/CcjCoordinator.cs
@@ -233,7 +233,9 @@ namespace WalletWasabi.Services
// If aborted in signing phase, then ban Alices those didn't sign.
if (status == CcjRoundStatus.Aborted && round.Phase == CcjRoundPhase.Signing)
{
- foreach (Alice alice in round.GetAlicesByNot(AliceState.SignedCoinJoin, syncLock: false)) // Because the event sometimes is raised from inside the lock.
+ IEnumerable<Alice> alicesDidntSign = round.GetAlicesByNot(AliceState.SignedCoinJoin, syncLock: false);
+
+ foreach (Alice alice in alicesDidntSign) // Because the event sometimes is raised from inside the lock.
{
// If its from any coinjoin, then don't ban.
IEnumerable<OutPoint> utxosToBan = alice.Inputs.Select(x => x.Outpoint);

Optimize backend code redundancy