Use Node.ConnectAsync instead of Node.Connect
MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -55,7 +55,7 @@ namespace WalletWasabi.Backend
await AssertRpcNodeFullyInitializedAsync();
// Make sure P2P works.
- InitializeP2p(config.Network, config.GetBitcoinCoreEndPoint());
+ await InitializeP2pAsync(config.Network, config.GetBitcoinCoreEndPoint());
// Initialize index building
var indexBuilderServiceDir = Path.Combine(DataDir, nameof(IndexBuilderService));
@@ -129,7 +129,7 @@ namespace WalletWasabi.Backend
}
}
- private static void InitializeP2p(Network network, IPEndPoint iPEndPoint)
+ private static async Task InitializeP2pAsync(Network network, IPEndPoint iPEndPoint)
{
Guard.NotNull(nameof(network), network);
Guard.NotNull(nameof(iPEndPoint), iPEndPoint);
@@ -144,7 +144,7 @@ namespace WalletWasabi.Backend
};
nodeConnectionParameters.TemplateBehaviors.Add(new TrustedNodeNotifyingBehavior());
- var node = Node.Connect(network, iPEndPoint, nodeConnectionParameters);
+ var node = await Node.ConnectAsync(network, iPEndPoint, nodeConnectionParameters);
// We have to find it, because it's cloned by the node and not perfectly cloned (event handlers cannot be cloned.)
TrustedNodeNotifyingBehavior = node.Behaviors.Find<TrustedNodeNotifyingBehavior>();
try

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -142,10 +142,10 @@ namespace WalletWasabi.Gui
InitializeConfig(config);
- InitializeNoWallet();
+ await InitializeNoWalletAsync();
}
- public static void InitializeNoWallet()
+ public static async Task InitializeNoWalletAsync()
{
WalletService = null;
ChaumianClient = null;
@@ -251,10 +251,10 @@ namespace WalletWasabi.Gui
Nodes = new NodesGroup(Network, requirements: Constants.NodeRequirements);
try
{
- Node node = Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
+ Node node = await Node.ConnectAsync(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
Nodes.ConnectedNodes.Add(node);
- RegTestMemPoolServingNode = Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
+ RegTestMemPoolServingNode = await Node.ConnectAsync(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
RegTestMemPoolServingNode.Behaviors.Add(new MemPoolBehavior(MemPoolService));
}

MODIFY
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
@@ -68,15 +68,9 @@ namespace WalletWasabi.Tests.NodeBuilding
return new RPCClient(Creds, new Uri("http://127.0.0.1:" + _ports[1] + "/"), Network.RegTest);
}
- public Node CreateNodeClient()
- {
- return Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, _ports[0]));
- }
+ public async Task<Node> CreateNodeClientAsync() => await Node.ConnectAsync(Network.RegTest, new IPEndPoint(IPAddress.Loopback, _ports[0]));
- public Node CreateNodeClient(NodeConnectionParameters parameters)
- {
- return Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, _ports[0]), parameters);
- }
+ public async Task<Node> CreateNodeClientAsync(NodeConnectionParameters parameters) => await Node.ConnectAsync(Network.RegTest, new IPEndPoint(IPAddress.Loopback, _ports[0]), parameters);
public async Task StartAsync()
{
@@ -162,9 +156,9 @@ namespace WalletWasabi.Tests.NodeBuilding
}
}
- public void BroadcastBlocks(IEnumerable<Block> blocks)
+ public async Task BroadcastBlocksAsync(IEnumerable<Block> blocks)
{
- using (var node = CreateNodeClient())
+ using (var node = await CreateNodeClientAsync())
{
node.VersionHandshake();
BroadcastBlocks(blocks, node);

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -255,7 +255,7 @@ namespace WalletWasabi.Tests
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration) = await InitializeTestEnvironmentAsync(1);
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
node.VersionHandshake();
@@ -297,7 +297,6 @@ namespace WalletWasabi.Tests
Logger.LogDebug<RegTests>($"Mempool transaction received: {e.GetHash()}.");
}
-
[Fact]
public async Task FilterDownloaderTestAsync()
{
@@ -495,12 +494,12 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
memPoolService.TransactionReceived += WalletTestsAsync_MemPoolService_TransactionReceived;
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -725,11 +724,11 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -1169,11 +1168,11 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -1333,11 +1332,11 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -1498,11 +1497,11 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -1660,11 +1659,11 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
@@ -3274,18 +3273,18 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
var nodes2 = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
- nodes2.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
+ nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
var memPoolService = new MemPoolService();
- Node node = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
var memPoolService2 = new MemPoolService();
- Node node2 = RegTestFixture.BackendRegTestNode.CreateNodeClient();
+ Node node2 = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
node2.Behaviors.Add(new MemPoolBehavior(memPoolService2));
// 3. Create wasabi synchronizer service.

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -687,7 +687,7 @@ namespace WalletWasabi.Services
};
var localIpEndPoint = ServiceConfiguration.BitcoinCoreEndPoint;
- var localNode = Node.Connect(Network, localIpEndPoint, nodeConnectionParameters);
+ var localNode = await Node.ConnectAsync(Network, localIpEndPoint, nodeConnectionParameters);
try
{
Logger.LogInfo<WalletService>($"TCP Connection succeeded, handshaking...");

MODIFY
WalletWasabi/WalletWasabi.csproj
WalletWasabi/WalletWasabi.csproj
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="NBitcoin" Version="4.1.1.86" />
+ <PackageReference Include="NBitcoin" Version="4.1.1.94" />
</ItemGroup>
<ItemGroup>

Use Node.ConnectAsync instead of Node.Connect