Simplify algorithm
MODIFY
WalletWasabi/Stores/IndexStore.cs
WalletWasabi/Stores/IndexStore.cs
@@ -109,7 +109,7 @@ public class IndexStore : IAsyncDisposable
{
i++;
cancel.ThrowIfCancellationRequested();
- string? line = await sr.ReadLineAsync().ConfigureAwait(false);
+ string? line = await sr.ReadLineAsync(CancellationToken.None).ConfigureAwait(false);
if (line is null)
{
@@ -362,48 +362,19 @@ public class IndexStore : IAsyncDisposable
{
uint height = StartingHeight;
using var sr = MatureIndexFileManager.OpenText();
- if (!sr.EndOfStream)
- {
- var lineTask = sr.ReadLineAsync();
- Task tTask = Task.CompletedTask;
- string? line = null;
- while (lineTask is { })
+
+ while (true)
{
if (firstImmatureHeight == height)
{
break; // Let's use our the immature filters from here on. The content is the same, just someone else modified the file.
}
- line ??= await lineTask.ConfigureAwait(false);
-
- lineTask = sr.EndOfStream ? null : sr.ReadLineAsync();
-
- if (height < fromHeight.Value)
- {
- height++;
- line = null;
- continue;
- }
-
- var filter = FilterModel.FromLine(line);
-
- await tTask.ConfigureAwait(false);
- tTask = todo(filter);
-
- height++;
-
- line = null;
- }
- await tTask.ConfigureAwait(false);
- }
-
- while (!sr.EndOfStream)
- {
- var line = await sr.ReadLineAsync().ConfigureAwait(false);
+ string? line = await sr.ReadLineAsync(CancellationToken.None).ConfigureAwait(false);
- if (firstImmatureHeight == height)
+ if (line is null)
{
- break; // Let's use our the immature filters from here on. The content is the same, just someone else modified the file.
+ break;
}
if (height < fromHeight.Value)
@@ -412,7 +383,7 @@ public class IndexStore : IAsyncDisposable
continue;
}
- var filter = FilterModel.FromLine(line);
+ FilterModel filter = FilterModel.FromLine(line);
await todo(filter).ConfigureAwait(false);
height++;

Simplify algorithm

(cherry picked from commit 752469f9de4d9fa5ef74ed3284b93898c614a9ec)