fix developer lazyness
MODIFY
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
@@ -90,7 +90,7 @@ namespace WalletWasabi.Tests.UnitTests
public void CanHandleGap()
{
string password = "password";
- var manager = KeyManager.CreateNew(out Mnemonic mnemonic, password);
+ var manager = KeyManager.CreateNew(out _, password);
manager.AssertCleanKeysIndexed();
var lastKey = manager.GetKeys(KeyState.Clean, isInternal: false).Last();

MODIFY
WalletWasabi/Blockchain/Keys/KeyManager.cs
WalletWasabi/Blockchain/Keys/KeyManager.cs
@@ -532,27 +532,27 @@ namespace WalletWasabi.Blockchain.Keys
public int GetConsecutiveKeysCount(KeyState? keyState = null, bool? isInternal = null)
{
- var keys = GetKeys(KeyState.Clean, isInternal);
- var keyCount = keys.Count();
- if (keyCount < 2) return keyCount;
+ var keys = GetKeys(KeyState.Clean, isInternal).ToArray();
+ var keyCount = keys.Length;
+ if (keyCount < 2)
+ {
+ return keyCount;
+ }
var largerConsecutiveSequence = 1;
var consecutives = 1;
for (int i = 1; i < keyCount; i++)
{
- if(keys.ElementAt(i).Index == keys.ElementAt(i-1).Index + 1)
+ if (keys[i].Index == keys[i - 1].Index + 1)
{
consecutives++;
}
- else
- {
- if(consecutives > largerConsecutiveSequence)
+ else if (consecutives > largerConsecutiveSequence)
{
largerConsecutiveSequence = consecutives;
consecutives = 1;
}
}
- }
return Math.Max(consecutives, largerConsecutiveSequence);
}

fix developer lazyness