Put IndexStore into BitcoinStore
MODIFY
WalletWasabi/Stores/BitcoinStore.cs
WalletWasabi/Stores/BitcoinStore.cs
+using NBitcoin;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.Helpers;
namespace WalletWasabi.Stores
{
@@ -10,5 +14,21 @@ namespace WalletWasabi.Stores
/// </summary>
public class BitcoinStore
{
+ private string WorkFolderPath { get; set; }
+ private Network Network { get; set; }
+
+ public IndexStore IndexStore { get; private set; }
+
+ public async Task InitializeAsync(string workFolderPath, Network network)
+ {
+ WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true);
+ IoHelpers.EnsureDirectoryExists(WorkFolderPath);
+
+ Network = Guard.NotNull(nameof(network), network);
+
+ IndexStore = new IndexStore();
+ var indexStoreFolderPath = Path.Combine(WorkFolderPath, Network.ToString());
+ await IndexStore.InitializeAsync(indexStoreFolderPath, Network);
+ }
}
}

MODIFY
WalletWasabi/Stores/IndexStore.cs
WalletWasabi/Stores/IndexStore.cs
@@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Backend.Models;
using WalletWasabi.Helpers;
+using WalletWasabi.Logging;
using WalletWasabi.Models;
using WalletWasabi.Services;
@@ -24,13 +25,13 @@ namespace WalletWasabi.Stores
private FilterModel StartingFilter { get; set; }
private Height StartingHeight { get; set; }
-
- private object IndexLock { get; set; }
private List<FilterModel> Index { get; set; }
public async Task InitializeAsync(string workFolderPath, Network network)
{
WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true);
+ IoHelpers.EnsureDirectoryExists(WorkFolderPath);
+
Network = Guard.NotNull(nameof(network), network);
IndexFilePath = Path.Combine(WorkFolderPath, IndexFileName);
@@ -39,8 +40,6 @@ namespace WalletWasabi.Stores
Index = new List<FilterModel>();
- IoHelpers.EnsureDirectoryExists(WorkFolderPath);
-
if (Network == Network.RegTest)
{
IoHelpers.BetterDelete(IndexFilePath); // RegTest is not a global ledger, better to delete it.

Put IndexStore into BitcoinStore