Make sure max non-onion connection count is based on max node count
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -342,7 +342,9 @@ namespace WalletWasabi.Gui
private NodesGroup CreateAndConfigureNodesGroup(NodeConnectionParameters connectionParameters)
{
- var bestEffortEndpointConnector = new BestEffortEndpointConnector();
+ var maximumNodeConnection = 12;
+ var maximumNonOnionConnection = 6;
+ var bestEffortEndpointConnector = new BestEffortEndpointConnector(maximumNonOnionConnection);
connectionParameters.EndpointConnector = bestEffortEndpointConnector;
if (Config.UseTor)
{
@@ -351,7 +353,7 @@ namespace WalletWasabi.Gui
var nodes = new NodesGroup(Network, connectionParameters, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Added += ConnectedNodes_OnAddedOrRemoved;
nodes.ConnectedNodes.Removed += ConnectedNodes_OnAddedOrRemoved;
- nodes.MaximumNodeConnection = 12;
+ nodes.MaximumNodeConnection = maximumNodeConnection;
return nodes;
}

MODIFY
WalletWasabi.Tests/UnitTests/BestEffortEndpointConnectorTests.cs
WalletWasabi.Tests/UnitTests/BestEffortEndpointConnectorTests.cs
@@ -16,7 +16,7 @@ namespace WalletWasabi.Tests.UnitTests
[Fact]
public async Task CanConnectWithDifferentModesAsync()
{
- var connector = new BestEffortEndpointConnector();
+ var connector = new BestEffortEndpointConnector(6);
var nodeConnectionParameters = new NodeConnectionParameters();
nodeConnectionParameters.TemplateBehaviors.Add(new SocksSettingsBehavior(new IPEndPoint(IPAddress.Loopback, 8090), onlyForOnionHosts: true, networkCredential: null, streamIsolation: true));

MODIFY
WalletWasabi/BestEffortEndpointConnector.cs
WalletWasabi/BestEffortEndpointConnector.cs
@@ -15,8 +15,8 @@ namespace WalletWasabi
{
public class BestEffortEndpointConnector : IEnpointConnector
{
- public BestEffortEndpointConnector()
- : this(new EffortState())
+ public BestEffortEndpointConnector(long maxNonOnionConnectionCount)
+ : this(new EffortState(maxNonOnionConnectionCount))
{
}
@@ -84,8 +84,9 @@ namespace WalletWasabi
{
private bool _allowAnyConnetionType;
- public EffortState()
+ public EffortState(long maxNonOnionConnectionCount)
{
+ MaxNonOnionConnectionCount = maxNonOnionConnectionCount;
}
public long ConnectedNodesCount { get; set; }
@@ -94,7 +95,7 @@ namespace WalletWasabi
{
get
{
- var allowAnyConnetionType = ConnectedNodesCount <= 6;
+ var allowAnyConnetionType = ConnectedNodesCount <= MaxNonOnionConnectionCount;
if (_allowAnyConnetionType != allowAnyConnetionType)
{
@@ -106,6 +107,8 @@ namespace WalletWasabi
}
}
+ public long MaxNonOnionConnectionCount { get; }
+
public override string ToString()
{
return $"Connections: {ConnectedNodesCount}, Currently allow only onions: {!_allowAnyConnetionType}.";

Make sure max non-onion connection count is based on max node count