-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to have more than min_peers/2 outbound peers #2537
Allow to have more than min_peers/2 outbound peers #2537
Conversation
Default value is 8, so we allow only 4 outbound peers, unfortunately if a node is behind NAT it can't get inbound peers and it stucks with 4 peers as maximum. This PR allows a number of outbound peers to be between min_peers and max_peers/2. Node behind NAT will eventually have just min_peers number of peers.
Another option is to keep the second condition as |
We do something similar to what you propose in Lines 189 to 194 in 1f7ea49
Here we keep the "total peer count" below I wonder if we should look at both "total peer count" and "total outbound peer count" as you suggest, in i.e. We go try and connect to more outbound peers if -
That way we handle nodes behind NAT by just looking at total peers (we will never have inbound peers) I think it may make sense to keep the |
Good catch by the way - I don't think the NAT case was fully considered here when we split out default 8 slots into inbound/outbound. |
I tested the latest version of this PR - after 20 mins a node behind NAT oscillates around 8 peers in total (all outbound), a node with a public IP has 4 outbounds (55 in the first seconds) and 100+ inbounds. |
Ah, I pushed to the origin by mistake, removed the branch but Travis noticed it and now tries to build this removed branch too, please ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this looks good.
} | ||
|
||
/// We have enough peers, both total connected and outbound connected | ||
pub fn healthy_peers_mix(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Default value is 8, so we allow only 4 outbound peers, unfortunately if a node is behind NAT it can't get inbound peers and it stucks with 4 peers as maximum.
This PR allows a number of outbound peers to be between min_peers and max_peers/2. Node behind NAT will eventually have just min_peers number of peers.