BitcoinStore: Pass parameters to the class's constructor rather than `InitializeAsync()`
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -48,7 +48,7 @@ namespace WalletWasabi.Gui
public string DataDir { get; }
public string TorLogsFile { get; }
- public BitcoinStore BitcoinStore { get; private set; }
+ public BitcoinStore BitcoinStore { get; }
public LegalDocuments LegalDocuments { get; set; }
public Config Config { get; }
@@ -101,6 +101,8 @@ namespace WalletWasabi.Gui
WalletManager.OnDequeue += WalletManager_OnDequeue;
WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed;
+
+ BitcoinStore = new BitcoinStore(Path.Combine(DataDir, "BitcoinStore"), Network);
}
}
@@ -124,8 +126,7 @@ namespace WalletWasabi.Gui
SizeLimit = 1_000,
ExpirationScanFrequency = TimeSpan.FromSeconds(30)
});
- BitcoinStore = new BitcoinStore();
- var bstoreInitTask = BitcoinStore.InitializeAsync(Path.Combine(DataDir, "BitcoinStore"), Network);
+ var bstoreInitTask = BitcoinStore.InitializeAsync();
var addressManagerFolderPath = Path.Combine(DataDir, "AddressManager");
AddressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{Network}.dat");

MODIFY
WalletWasabi/Stores/BitcoinStore.cs
WalletWasabi/Stores/BitcoinStore.cs
@@ -20,13 +20,13 @@ namespace WalletWasabi.Stores
public class BitcoinStore
{
public bool IsInitialized { get; private set; }
- private string WorkFolderPath { get; set; }
- public Network Network { get; private set; }
+ private string WorkFolderPath { get;}
+ public Network Network { get;}
- public IndexStore IndexStore { get; private set; }
- public AllTransactionStore TransactionStore { get; private set; }
- public SmartHeaderChain SmartHeaderChain { get; private set; }
- public MempoolService MempoolService { get; private set; }
+ public IndexStore IndexStore { get; }
+ public AllTransactionStore TransactionStore { get; }
+ public SmartHeaderChain SmartHeaderChain { get; }
+ public MempoolService MempoolService { get; }
/// <summary>
/// This should not be a property, but a creator function, because it'll be cloned left and right by NBitcoin later.
@@ -34,9 +34,7 @@ namespace WalletWasabi.Stores
/// </summary>
public UntrustedP2pBehavior CreateUntrustedP2pBehavior() => new UntrustedP2pBehavior(MempoolService);
- public async Task InitializeAsync(string workFolderPath, Network network)
- {
- using (BenchmarkLogger.Measure())
+ public BitcoinStore(string workFolderPath, Network network)
{
WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true);
IoHelpers.EnsureDirectoryExists(WorkFolderPath);
@@ -45,10 +43,16 @@ namespace WalletWasabi.Stores
IndexStore = new IndexStore();
TransactionStore = new AllTransactionStore();
- var networkWorkFolderPath = Path.Combine(WorkFolderPath, Network.ToString());
- var indexStoreFolderPath = Path.Combine(networkWorkFolderPath, "IndexStore");
SmartHeaderChain = new SmartHeaderChain();
MempoolService = new MempoolService();
+ }
+
+ public async Task InitializeAsync()
+ {
+ using (BenchmarkLogger.Measure())
+ {
+ var networkWorkFolderPath = Path.Combine(WorkFolderPath, Network.ToString());
+ var indexStoreFolderPath = Path.Combine(networkWorkFolderPath, "IndexStore");
var initTasks = new[]
{

BitcoinStore: Pass parameters to the class's constructor rather than `InitializeAsync()`