This fixes a long standing issue whereby the node would stop receiving inbound connections.
The bug is that we add the connected peer to the network peer disposer after it has been disconnected because of a ban. The result is that the connected peers collection in the network peer disposer constantly increases as we never have the peer in the collection by the time the other node has disconnected it due to a ban. Eventually the max inbound count is reached and the node stops incoming connections here:
if (this.networkPeerDisposer.ConnectedInboundPeersCount >= this.connectionManagerSettings.MaxInboundConnections)
{
this.logger.LogTrace("(-)[MAX_CONNECTION_THRESHOLD_REACHED]:false");
return (false, $"Inbound Refused: Max Inbound Connection Threshold Reached, inbounds: {this.networkPeerDisposer.ConnectedInboundPeersCount}");
}
It has been decided that to fix the race condition is unnecessary as we shouldn't even be allowing the inbound when it is banned.
This fixes a long standing issue whereby the node would stop receiving inbound connections.
The bug is that we add the connected peer to the network peer disposer after it has been disconnected because of a ban. The result is that the connected peers collection in the network peer disposer constantly increases as we never have the peer in the collection by the time the other node has disconnected it due to a ban. Eventually the max inbound count is reached and the node stops incoming connections here:
It has been decided that to fix the race condition is unnecessary as we shouldn't even be allowing the inbound when it is banned.