-
Notifications
You must be signed in to change notification settings - Fork 992
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
Map peers by ip only (ignoring port unless on loopback ip) #2540
Conversation
Makes sense to me! |
782629f
to
1298b4a
Compare
@ignopeverell @yeastplume @hashmap this is ready for final review.
This was a bigger change than I initially anticipated, but I think its worth it. Currently testing public and private nodes on mainnet and things appear to be running smoothly so far. |
Look at all those peers -
10,000 defunct peers... 🙈 |
Working on getting |
e245a8a
to
9adbeea
Compare
These now work -
|
If we change default port 3414 its break peer count limits |
@nikito7 can you explain what you mean here? We effectively ignore the port when identifying peers, we don't assume they are on 3414. If you have a peer running on |
We have chunks of logic in our peering code that explicitly ignores the port when looking at peer addresses.
But we still store peers, both in the db and in our connected peers map based on
ip:port
.This appears to cause some unnecessary complexity as we sometimes iterate over them all, comparing the ip and ignoring the port.
This PR attempts to clean this up and consolidate the "do we include the port or ignore the port?" logic based on whether our peer is on the "loopback" address or not.
i.e. If we are running tests or running a usernet locally then we care about the port.
But in all other cases we ignore the port and just treat each ip as having a single node on a single port.
Note we still store the peer ip and port, we just don't take the port into account when creating the key for it in the db or the connected peers map.
Thoughts on this?
It runs locally with tests fine. It also appears to run happily against
mainnet
.TODO -
PeerAddr
struct so we can encapsulate the key creation logic in one place (currently duplicated in bothpeers.rs
andstore.rs
)SockAddr
and rename itPeerAddr
(turning into a big can of worms)