Update code for using the new Height operators
MODIFY
MagicalCryptoWallet.Tests/P2pTests.cs
MagicalCryptoWallet.Tests/P2pTests.cs
@@ -250,7 +250,7 @@ namespace MagicalCryptoWallet.Tests
for (int i = 0; i < 111; i++)
{
var expectedHash = await rpc.GetBlockHashAsync(i + 1);
- var filterModel = FilterModel.FromLine(filters[i], new Height(i));
+ var filterModel = FilterModel.FromLine(filters[i], i);
Assert.Equal(expectedHash, filterModel.BlockHash);
Assert.Null(filterModel.Filter);
}

MODIFY
MagicalCryptoWallet/Services/IndexBuilderService.cs
MagicalCryptoWallet/Services/IndexBuilderService.cs
@@ -144,10 +144,10 @@ namespace MagicalCryptoWallet.Services
}
else
{
- int height = StartingHeight.Value;
+ var height = StartingHeight;
foreach (var line in File.ReadAllLines(IndexFilePath))
{
- var filter = FilterModel.FromLine(line, new Height(height));
+ var filter = FilterModel.FromLine(line, height);
height++;
Index.Add(filter);
}
@@ -195,18 +195,19 @@ namespace MagicalCryptoWallet.Services
// If stop was requested return.
if (IsRunning == false) return;
- int height = StartingHeight.Value;
+ var height = StartingHeight;
uint256 prevHash = null;
using (await IndexLock.LockAsync())
{
if (Index.Count != 0)
{
- height = Index.Last().BlockHeight.Value + 1;
- prevHash = Index.Last().BlockHash;
+ var lastIndex = Index.Last();
+ height = lastIndex.BlockHeight + 1;
+ prevHash = lastIndex.BlockHash;
}
}
- if (blockCount - height <= 100)
+ if (blockCount - (int)height <= 100)
{
isIIB = false;
}
@@ -312,7 +313,7 @@ namespace MagicalCryptoWallet.Services
var filterModel = new FilterModel
{
BlockHash = block.GetHash(),
- BlockHeight = new Height(height),
+ BlockHeight = height,
Filter = filter
};

MODIFY
MagicalCryptoWallet/Services/IndexDownloader.cs
MagicalCryptoWallet/Services/IndexDownloader.cs
@@ -90,10 +90,10 @@ namespace MagicalCryptoWallet.Services
}
else
{
- int height = StartingHeight.Value;
+ var height = StartingHeight;
foreach (var line in File.ReadAllLines(IndexFilePath))
{
- var filter = FilterModel.FromLine(line, new Height(height));
+ var filter = FilterModel.FromLine(line, height);
height++;
Index.Add(filter);
}
@@ -141,7 +141,7 @@ namespace MagicalCryptoWallet.Services
{
for (int i = 0; i < filters.Count; i++)
{
- var filterModel = FilterModel.FromLine(filters[i], new Height(bestKnownFilter.BlockHeight.Value + i + 1));
+ var filterModel = FilterModel.FromLine(filters[i], bestKnownFilter.BlockHeight + i + 1);
Index.Add(filterModel);
OnNewFilter(filterModel);

Update code for using the new Height operators