Moved predicate, removes redundant where call
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -656,7 +656,7 @@ namespace WalletWasabi.Tests
Assert.Equal(4, wallet.Coins.Count);
Assert.Empty(wallet.Coins.Where(x => x.TransactionId == txid4));
Assert.NotEmpty(wallet.Coins.Where(x => x.TransactionId == tx4bumpRes.TransactionId));
- var rbfCoin = wallet.Coins.Where(x => x.TransactionId == tx4bumpRes.TransactionId).Single();
+ var rbfCoin = wallet.Coins.Single(x => x.TransactionId == tx4bumpRes.TransactionId);
Assert.Equal(Money.Coins(0.03m), rbfCoin.Amount);
Assert.Equal(new Height(bitcoinStore.HashChain.TipHeight).Value - 2, rbfCoin.Height.Value);
@@ -686,7 +686,7 @@ namespace WalletWasabi.Tests
var txid5 = await rpc.SendToAddressAsync(key.GetP2wpkhAddress(network), Money.Coins(0.1m));
await Task.Delay(1000); // Wait tx to arrive and get processed.
Assert.NotEmpty(wallet.Coins.Where(x => x.TransactionId == txid5));
- var mempoolCoin = wallet.Coins.Where(x => x.TransactionId == txid5).Single();
+ var mempoolCoin = wallet.Coins.Single(x => x.TransactionId == txid5);
Assert.Equal(Height.MemPool, mempoolCoin.Height);
Interlocked.Exchange(ref _filtersProcessedByWalletCount, 0);
@@ -3428,7 +3428,7 @@ namespace WalletWasabi.Tests
}
var times = 0;
- while (wallet.Coins.Where(x => x.Label == "ZeroLink Change" && x.Unspent).FirstOrDefault() is null)
+ while (wallet.Coins.FirstOrDefault(x => x.Label == "ZeroLink Change" && x.Unspent) is null)
{
await Task.Delay(1000);
times++;

MODIFY
WalletWasabi/Models/AllFeeEstimate.cs
WalletWasabi/Models/AllFeeEstimate.cs
@@ -41,9 +41,9 @@ namespace WalletWasabi.Models
public Money GetFeeRate(int feeTarget)
{
+ // Where the target is still under or equals to the the requested target.
int satoshiPerByte = Estimations
- .Where(x => x.Key <= feeTarget) // Where the target is still under or equals to the the requested target.
- .Last() // The last should be the largest feeTarget.
+ .Last(x => x.Key <= feeTarget) // The last should be the largest feeTarget.
.Value;
return Money.Satoshis(satoshiPerByte);

MODIFY
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
@@ -407,7 +407,7 @@ namespace Nito.AsyncEx
{
lock (AsyncMutexesLock)
{
- bool stillRunning = AsyncMutexes.Where(am => am.Value.IsAlive).Any();
+ bool stillRunning = AsyncMutexes.Any(am => am.Value.IsAlive);
if (!stillRunning)
{
return;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -448,7 +448,7 @@ namespace WalletWasabi.Services
// If it spends someone and hasn't been sufficiently anonymized.
if (coin.AnonymitySet < ServiceConfiguration.PrivacyLevelStrong)
{
- var c = lookupSpenderTransactionId[coin.TransactionId].Where(x => !clusters.Contains(x)).FirstOrDefault();
+ var c = lookupSpenderTransactionId[coin.TransactionId].FirstOrDefault(x => !clusters.Contains(x));
if (c != default)
{
var h = GetClusters(c, clusters, lookupScriptPubKey, lookupSpenderTransactionId, lookupTransactionId);
@@ -465,7 +465,7 @@ namespace WalletWasabi.Services
// If it's being spent by someone and that someone hasn't been sufficiently anonymized.
if (!coin.Unspent)
{
- var c = lookupTransactionId[coin.SpenderTransactionId].Where(x => !clusters.Contains(x)).FirstOrDefault();
+ var c = lookupTransactionId[coin.SpenderTransactionId].FirstOrDefault(x => !clusters.Contains(x));
if (c != default)
{
if (c.AnonymitySet < ServiceConfiguration.PrivacyLevelStrong)

Moved predicate, removes redundant where call