AllTransactionStore: Make `Network` to be a constructor parameter
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -104,7 +104,7 @@ namespace WalletWasabi.Gui
BitcoinStore = new BitcoinStore(
Path.Combine(DataDir, "BitcoinStore"), Network,
- indexStore, new AllTransactionStore(), new MempoolService()
+ indexStore, new AllTransactionStore(Network), new MempoolService()
);
SingleInstanceChecker = new SingleInstanceChecker(Network);

MODIFY
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
@@ -58,7 +58,7 @@ namespace WalletWasabi.Tests.IntegrationTests
var dataDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetCallerFileName());
BitcoinStore bitcoinStore = new BitcoinStore(Path.Combine(dataDir, EnvironmentHelpers.GetMethodName()), network,
- new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(), new MempoolService());
+ new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(network), new MempoolService());
await bitcoinStore.InitializeAsync();
var addressManagerFolderPath = Path.Combine(dataDir, "AddressManager");

MODIFY
WalletWasabi.Tests/RegressionTests/Common.cs
WalletWasabi.Tests/RegressionTests/Common.cs
@@ -90,7 +90,7 @@ namespace WalletWasabi.Tests.RegressionTests
var serviceConfiguration = new ServiceConfiguration(MixUntilAnonymitySet.PrivacyLevelSome.ToString(), 2, 21, 50, regTestFixture.BackendRegTestNode.P2pEndPoint, Money.Coins(Constants.DefaultDustThreshold));
var dir = GetWorkDir(callerFilePath, callerMemberName);
- var bitcoinStore = new BitcoinStore(dir, network, new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(), new MempoolService());
+ var bitcoinStore = new BitcoinStore(dir, network, new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(network), new MempoolService());
await bitcoinStore.InitializeAsync();
return ("password", global.RpcClient, network, global.Coordinator, serviceConfiguration, bitcoinStore, global);
}

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
var network = coreNode.Network;
var rpc = coreNode.RpcClient;
var dir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetCallerFileName(), EnvironmentHelpers.GetMethodName());
- var bitcoinStore = new BitcoinStore(dir, network, new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(), new MempoolService());
+ var bitcoinStore = new BitcoinStore(dir, network, new IndexStore(network, new SmartHeaderChain()), new AllTransactionStore(network), new MempoolService());
await bitcoinStore.InitializeAsync();
await rpc.GenerateAsync(101);

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/AllTransactionStoreTests.cs
WalletWasabi.Tests/UnitTests/Transactions/AllTransactionStoreTests.cs
@@ -77,9 +77,9 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
[MemberData(nameof(GetDifferentNetworkValues))]
public async Task CanInitializeEmptyAsync(Network network)
{
- var txStore = new AllTransactionStore();
+ var txStore = new AllTransactionStore(network);
var dir = PrepareWorkDir();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
Assert.NotNull(txStore.ConfirmedStore);
Assert.NotNull(txStore.MempoolStore);
@@ -138,8 +138,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
Assert.Equal(6, txStore.GetTransactions().Count());
Assert.Equal(6, txStore.GetTransactionHashes().Count());
@@ -196,8 +196,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
Assert.Equal(6, txStore.GetTransactions().Count());
Assert.Equal(6, txStore.GetTransactionHashes().Count());
@@ -231,8 +231,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
Assert.Equal(6, txStore.GetTransactions().Count());
Assert.Equal(2, txStore.MempoolStore.GetTransactions().Count());
@@ -269,8 +269,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
Assert.Equal(6, txStore.GetTransactions().Count());
Assert.Equal(2, txStore.MempoolStore.GetTransactions().Count());
@@ -310,8 +310,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
var txs = txStore.GetTransactions();
var txHashes = txStore.GetTransactionHashes();
@@ -328,8 +328,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.Equal(txHashes, txs.Select(x => x.GetHash()));
Assert.Equal(expectedArray, txs);
- txStore = new AllTransactionStore();
- await txStore.InitializeAsync(PrepareWorkDir(), network, ensureBackwardsCompatibility: false);
+ txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(PrepareWorkDir(), ensureBackwardsCompatibility: false);
txStore.AddOrUpdate(uTx3);
txStore.AddOrUpdate(uTx1);
@@ -349,8 +349,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
[MemberData(nameof(GetDifferentNetworkValues))]
public async Task DoesntUpdateAsync(Network network)
{
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(PrepareWorkDir(), network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(PrepareWorkDir(), ensureBackwardsCompatibility: false);
var tx = Global.GenerateRandomSmartTransaction();
Assert.False(txStore.TryUpdate(tx));
@@ -401,8 +401,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
await File.WriteAllLinesAsync(mempoolFile, mempoolFileContent);
await File.WriteAllLinesAsync(txFile, txFileContent);
- var txStore = new AllTransactionStore();
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
// Two transactions are in the mempool store and unconfirmed.
Assert.True(txStore.MempoolStore.TryGetTransaction(uTx1.GetHash(), out SmartTransaction myUnconfirmedTx1));
@@ -446,9 +446,9 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
int transactionsPerBlock = 3;
string dir = PrepareWorkDir();
- var txStore = new AllTransactionStore();
var network = Network.Main;
- await txStore.InitializeAsync(dir, network, ensureBackwardsCompatibility: false);
+ var txStore = new AllTransactionStore(network);
+ await txStore.InitializeAsync(dir, ensureBackwardsCompatibility: false);
foreach (var height in Enumerable.Range(1, blocks))
{

MODIFY
WalletWasabi/Blockchain/Transactions/AllTransactionStore.cs
WalletWasabi/Blockchain/Transactions/AllTransactionStore.cs
@@ -14,21 +14,25 @@ namespace WalletWasabi.Blockchain.Transactions
{
public class AllTransactionStore
{
+ public AllTransactionStore(Network network)
+ {
+ Network = Guard.NotNull(nameof(network), network);
+ }
+
#region Initializers
private string WorkFolderPath { get; set; }
- private Network Network { get; set; }
+ private Network Network { get; }
public TransactionStore MempoolStore { get; private set; }
public TransactionStore ConfirmedStore { get; private set; }
private object Lock { get; set; }
- public async Task InitializeAsync(string workFolderPath, Network network, bool ensureBackwardsCompatibility = true)
+ public async Task InitializeAsync(string workFolderPath, bool ensureBackwardsCompatibility = true)
{
using (BenchmarkLogger.Measure())
{
WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true);
- Network = Guard.NotNull(nameof(network), network);
MempoolStore = new TransactionStore();
ConfirmedStore = new TransactionStore();

MODIFY
WalletWasabi/Stores/BitcoinStore.cs
WalletWasabi/Stores/BitcoinStore.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Stores
var initTasks = new[]
{
IndexStore.InitializeAsync(indexStoreFolderPath),
- TransactionStore.InitializeAsync(networkWorkFolderPath, Network)
+ TransactionStore.InitializeAsync(networkWorkFolderPath)
};
await Task.WhenAll(initTasks).ConfigureAwait(false);

AllTransactionStore: Make `Network` to be a constructor parameter