put MempoolService and MempoolBehavior to BitcoinStore
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -51,7 +51,6 @@ namespace WalletWasabi.Gui
public string AddressManagerFilePath { get; private set; }
public AddressManager AddressManager { get; private set; }
- public MempoolService MempoolService { get; private set; }
public NodesGroup Nodes { get; private set; }
public WasabiSynchronizer Synchronizer { get; private set; }
@@ -201,19 +200,18 @@ namespace WalletWasabi.Gui
#endregion TorProcessInitialization
- #region MempoolInitialization
-
- MempoolService = new MempoolService();
- connectionParameters.TemplateBehaviors.Add(new MempoolBehavior(MempoolService));
-
- #endregion MempoolInitialization
-
#region BitcoinStoreInitialization
await bstoreInitTask;
#endregion BitcoinStoreInitialization
+ #region MempoolInitialization
+
+ connectionParameters.TemplateBehaviors.Add(BitcoinStore.CreateMempoolBehavior());
+
+ #endregion MempoolInitialization
+
#region AddressManagerInitialization
AddressManagerBehavior addressManagerBehavior = await addrManTask;
@@ -236,7 +234,7 @@ namespace WalletWasabi.Gui
RegTestMempoolServingNode = await Node.ConnectAsync(Network.RegTest, bitcoinCoreEndpoint);
- RegTestMempoolServingNode.Behaviors.Add(new MempoolBehavior(MempoolService));
+ RegTestMempoolServingNode.Behaviors.Add(BitcoinStore.CreateMempoolBehavior());
}
catch (SocketException ex)
{
@@ -413,7 +411,7 @@ namespace WalletWasabi.Gui
Logger.LogWarning(ex);
}
- WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, MempoolService, Nodes, DataDir, Config.ServiceConfiguration);
+ WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, Nodes, DataDir, Config.ServiceConfiguration);
ChaumianClient.Start();
Logger.LogInfo("Start Chaumian CoinJoin service...");

MODIFY
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
@@ -52,6 +52,9 @@ namespace WalletWasabi.Tests.IntegrationTests
throw new NotSupportedNetworkException(network);
}
+ BitcoinStore bitcoinStore = new BitcoinStore();
+ await bitcoinStore.InitializeAsync(Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName()), network);
+
var addressManagerFolderPath = Path.Combine(Global.Instance.DataDir, "AddressManager");
var addressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{network}.dat");
var blocksFolderPath = Path.Combine(Global.Instance.DataDir, "Blocks", network.ToString());
@@ -82,14 +85,10 @@ namespace WalletWasabi.Tests.IntegrationTests
}
connectionParameters.TemplateBehaviors.Add(new AddressManagerBehavior(addressManager));
- var mempoolService = new MempoolService();
- connectionParameters.TemplateBehaviors.Add(new MempoolBehavior(mempoolService));
+ connectionParameters.TemplateBehaviors.Add(bitcoinStore.CreateMempoolBehavior());
var nodes = new NodesGroup(network, connectionParameters, requirements: Constants.NodeRequirements);
- BitcoinStore bitcoinStore = new BitcoinStore();
- await bitcoinStore.InitializeAsync(Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName()), network);
-
KeyManager keyManager = KeyManager.CreateNew(out _, "password");
WasabiSynchronizer syncer = new WasabiSynchronizer(network, bitcoinStore, new Uri("http://localhost:12345"), Global.Instance.TorSocks5Endpoint);
WalletService walletService = new WalletService(
@@ -97,7 +96,6 @@ namespace WalletWasabi.Tests.IntegrationTests
keyManager,
syncer,
new CcjClient(syncer, network, keyManager, new Uri("http://localhost:12345"), Global.Instance.TorSocks5Endpoint),
- mempoolService,
nodes,
Global.Instance.DataDir,
new ServiceConfiguration(50, 2, 21, 50, new IPEndPoint(IPAddress.Loopback, network.DefaultPort), Money.Coins(0.0001m)));
@@ -105,7 +103,7 @@ namespace WalletWasabi.Tests.IntegrationTests
try
{
- mempoolService.TransactionReceived += MempoolService_TransactionReceived;
+ bitcoinStore.MempoolService.TransactionReceived += MempoolService_TransactionReceived;
nodes.Connect();
var times = 0;
@@ -142,7 +140,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
nodes.ConnectedNodes.Added -= ConnectedNodes_Added;
nodes.ConnectedNodes.Removed -= ConnectedNodes_Removed;
- mempoolService.TransactionReceived -= MempoolService_TransactionReceived;
+ bitcoinStore.MempoolService.TransactionReceived -= MempoolService_TransactionReceived;
// So next test will download the block.
foreach (var hash in blocksToDownload)

MODIFY
WalletWasabi.Tests/IntegrationTests/RegTests.cs
WalletWasabi.Tests/IntegrationTests/RegTests.cs
@@ -254,14 +254,13 @@ namespace WalletWasabi.Tests.IntegrationTests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
- var mempoolService = new MempoolService();
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
node.VersionHandshake();
try
{
- mempoolService.TransactionReceived += MempoolAsync_MempoolService_TransactionReceived;
+ bitcoinStore.MempoolService.TransactionReceived += MempoolAsync_MempoolService_TransactionReceived;
// Using the interlocked, not because it makes sense in this context, but to
// set an example that these values are often concurrency sensitive
@@ -285,7 +284,7 @@ namespace WalletWasabi.Tests.IntegrationTests
}
finally
{
- mempoolService.TransactionReceived -= MempoolAsync_MempoolService_TransactionReceived;
+ bitcoinStore.MempoolService.TransactionReceived -= MempoolAsync_MempoolService_TransactionReceived;
}
}
@@ -526,10 +525,10 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
- mempoolService.TransactionReceived += WalletTestsAsync_MempoolService_TransactionReceived;
+
+ bitcoinStore.MempoolService.TransactionReceived += WalletTestsAsync_MempoolService_TransactionReceived;
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -542,7 +541,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 5. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
// Get some money, make it confirm.
@@ -706,7 +705,7 @@ namespace WalletWasabi.Tests.IntegrationTests
await synchronizer?.StopAsync();
// Dispose mempool service.
- mempoolService.TransactionReceived -= WalletTestsAsync_MempoolService_TransactionReceived;
+ bitcoinStore.MempoolService.TransactionReceived -= WalletTestsAsync_MempoolService_TransactionReceived;
// Dispose connection service.
nodes?.Dispose();
@@ -758,9 +757,9 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -773,7 +772,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
// Get some money, make it confirm.
@@ -1232,9 +1231,9 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1247,7 +1246,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
var scp = new Key().ScriptPubKey;
@@ -1395,9 +1394,9 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1410,7 +1409,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);
@@ -1558,9 +1557,9 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1573,7 +1572,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);
@@ -1726,9 +1725,9 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1741,7 +1740,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);
@@ -1883,6 +1882,7 @@ namespace WalletWasabi.Tests.IntegrationTests
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
using var torClient = new TorHttpClient(baseUri, Global.Instance.TorSocks5Endpoint);
using var satoshiClient = new SatoshiClient(baseUri, null);
+
#region PostInputsGetStates
// <-------------------------->
@@ -2223,7 +2223,7 @@ namespace WalletWasabi.Tests.IntegrationTests
Assert.NotEqual(Guid.Empty, aliceClient.UniqueId);
Assert.True(aliceClient.RoundId > 0);
await aliceClient.PostUnConfirmationAsync();
- using var response = await torClient.SendAsync(HttpMethod.Post, $"/api/v{Constants.BackendMajorVersion}/btc/chaumiancoinjoin/unconfirmation?uniqueId={aliceClient.UniqueId}&roundId={aliceClient.RoundId}");
+ using HttpResponseMessage response = await torClient.SendAsync(HttpMethod.Post, $"/api/v{Constants.BackendMajorVersion}/btc/chaumiancoinjoin/unconfirmation?uniqueId={aliceClient.UniqueId}&roundId={aliceClient.RoundId}");
Assert.True(response.IsSuccessStatusCode);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal("Alice not found.", await response.Content.ReadAsJsonAsync<string>());
@@ -3312,13 +3312,12 @@ namespace WalletWasabi.Tests.IntegrationTests
nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
- var mempoolService = new MempoolService();
+
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node.Behaviors.Add(new MempoolBehavior(mempoolService));
+ node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
- var mempoolService2 = new MempoolService();
Node node2 = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
- node2.Behaviors.Add(new MempoolBehavior(mempoolService2));
+ node2.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -3338,11 +3337,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// 6. Create wallet service.
var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
- var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
+ var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
var workDir2 = Path.Combine(Global.Instance.DataDir, $"{EnvironmentHelpers.GetMethodName()}2");
- var wallet2 = new WalletService(bitcoinStore, keyManager2, synchronizer2, chaumianClient2, mempoolService2, nodes2, workDir2, serviceConfiguration);
+ var wallet2 = new WalletService(bitcoinStore, keyManager2, synchronizer2, chaumianClient2, nodes2, workDir2, serviceConfiguration);
// Get some money, make it confirm.
var key = wallet.GetReceiveKey(new SmartLabel("fundZeroLink"));

MODIFY
WalletWasabi/Services/TransactionProcessor.cs
WalletWasabi/Services/TransactionProcessor.cs
@@ -51,7 +51,7 @@ namespace WalletWasabi.Services
if (isFoundTx)
{
SmartTransaction foundTx = TransactionCache.FirstOrDefault(x => x == tx);
- if (foundTx != default(SmartTransaction)) // Must check again, because it's a concurrent collection!
+ if (foundTx != default) // Must check again, because it's a concurrent collection!
{
foundTx.SetHeight(tx.Height, tx.BlockHash, tx.BlockIndex);
walletRelevant = true;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -58,7 +58,6 @@ namespace WalletWasabi.Services
public KeyManager KeyManager { get; }
public WasabiSynchronizer Synchronizer { get; }
public CcjClient ChaumianClient { get; }
- public MempoolService Mempool { get; }
public NodesGroup Nodes { get; }
public string BlocksFolderPath { get; }
public string TransactionsFolderPath { get; }
@@ -91,7 +90,6 @@ namespace WalletWasabi.Services
KeyManager keyManager,
WasabiSynchronizer syncer,
CcjClient chaumianClient,
- MempoolService mempool,
NodesGroup nodes,
string workFolderDir,
ServiceConfiguration serviceConfiguration)
@@ -101,7 +99,6 @@ namespace WalletWasabi.Services
Nodes = Guard.NotNull(nameof(nodes), nodes);
Synchronizer = Guard.NotNull(nameof(syncer), syncer);
ChaumianClient = Guard.NotNull(nameof(chaumianClient), chaumianClient);
- Mempool = Guard.NotNull(nameof(mempool), mempool);
ServiceConfiguration = Guard.NotNull(nameof(serviceConfiguration), serviceConfiguration);
ProcessedBlocks = new ConcurrentDictionary<uint256, (Height height, DateTimeOffset dateTime)>();
@@ -159,7 +156,7 @@ namespace WalletWasabi.Services
BitcoinStore.IndexStore.NewFilter += IndexDownloader_NewFilterAsync;
BitcoinStore.IndexStore.Reorged += IndexDownloader_ReorgedAsync;
- Mempool.TransactionReceived += Mempool_TransactionReceivedAsync;
+ BitcoinStore.MempoolService.TransactionReceived += Mempool_TransactionReceivedAsync;
}
private void TransactionProcessor_CoinSpent(object sender, SmartCoin spentCoin)
@@ -200,7 +197,7 @@ namespace WalletWasabi.Services
}
var txToRemove = TryGetTxFromCache(toRemove.TransactionId);
- if (txToRemove != default(SmartTransaction))
+ if (txToRemove != default)
{
TransactionCache.TryRemove(txToRemove);
}
@@ -282,7 +279,7 @@ namespace WalletWasabi.Services
}
} while (Synchronizer.AreRequestsBlocked()); // If requests are blocked, delay mempool cleanup, because coinjoin answers are always priority.
- await Mempool?.TryPerformMempoolCleanupAsync(Synchronizer?.WasabiClient?.TorClient?.DestinationUriAction, Synchronizer?.WasabiClient?.TorClient?.TorSocks5EndPoint);
+ await BitcoinStore.MempoolService?.TryPerformMempoolCleanupAsync(Synchronizer?.WasabiClient?.TorClient?.DestinationUriAction, Synchronizer?.WasabiClient?.TorClient?.TorSocks5EndPoint);
}
catch (Exception ex)
{
@@ -1173,7 +1170,7 @@ namespace WalletWasabi.Services
private async Task BroadcastTransactionToNetworkNodeAsync(SmartTransaction transaction, Node node)
{
Logger.LogInfo($"Trying to broadcast transaction with random node ({node.RemoteSocketAddress}):{transaction.GetHash()}.");
- if (!Mempool.TryAddToBroadcastStore(transaction.Transaction, node.RemoteSocketEndpoint.ToString())) // So we'll reply to INV with this transaction.
+ if (!BitcoinStore.MempoolService.TryAddToBroadcastStore(transaction.Transaction, node.RemoteSocketEndpoint.ToString())) // So we'll reply to INV with this transaction.
{
Logger.LogWarning($"Transaction {transaction.GetHash()} was already present in the broadcast store.");
}
@@ -1184,7 +1181,7 @@ namespace WalletWasabi.Services
await node.SendMessageAsync(invPayload).WithCancellation(cts.Token); // ToDo: It's dangerous way to cancel. Implement proper cancellation to NBitcoin!
}
- if (Mempool.TryGetFromBroadcastStore(transaction.GetHash(), out TransactionBroadcastEntry entry))
+ if (BitcoinStore.MempoolService.TryGetFromBroadcastStore(transaction.GetHash(), out TransactionBroadcastEntry entry))
{
// Give 7 seconds for serving.
var timeout = 0;
@@ -1291,7 +1288,7 @@ namespace WalletWasabi.Services
}
finally
{
- Mempool.TryRemoveFromBroadcastStore(transaction.GetHash(), out _); // Remove it just to be sure. Probably has been removed previously.
+ BitcoinStore.MempoolService.TryRemoveFromBroadcastStore(transaction.GetHash(), out _); // Remove it just to be sure. Probably has been removed previously.
Interlocked.Decrement(ref SendCount);
}
}
@@ -1428,7 +1425,7 @@ namespace WalletWasabi.Services
BitcoinStore.IndexStore.NewFilter -= IndexDownloader_NewFilterAsync;
BitcoinStore.IndexStore.Reorged -= IndexDownloader_ReorgedAsync;
- Mempool.TransactionReceived -= Mempool_TransactionReceivedAsync;
+ BitcoinStore.MempoolService.TransactionReceived -= Mempool_TransactionReceivedAsync;
Coins.CollectionChanged -= Coins_CollectionChanged;
TransactionProcessor.CoinSpent -= TransactionProcessor_CoinSpent;
TransactionProcessor.CoinReceived -= TransactionProcessor_CoinReceivedAsync;

MODIFY
WalletWasabi/Stores/BitcoinStore.cs
WalletWasabi/Stores/BitcoinStore.cs
@@ -6,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.Mempool;
namespace WalletWasabi.Stores
{
@@ -20,6 +21,13 @@ namespace WalletWasabi.Stores
public IndexStore IndexStore { get; private set; }
public HashChain HashChain { get; private set; }
+ public MempoolService MempoolService { get; private set; }
+
+ /// <summary>
+ /// This should not be a property, but a creator function, because it'll be cloned left and right by NBitcoin later.
+ /// So it should not be assumed it's some singleton.
+ /// </summary>
+ public MempoolBehavior CreateMempoolBehavior() => new MempoolBehavior(MempoolService);
public async Task InitializeAsync(string workFolderPath, Network network)
{
@@ -33,6 +41,8 @@ namespace WalletWasabi.Stores
IndexStore = new IndexStore();
var indexStoreFolderPath = Path.Combine(WorkFolderPath, Network.ToString(), "IndexStore");
HashChain = new HashChain();
+ MempoolService = new MempoolService();
+
await IndexStore.InitializeAsync(indexStoreFolderPath, Network, HashChain).ConfigureAwait(false);
}
}

put MempoolService and MempoolBehavior to BitcoinStore