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
server: fix inbound/outbound peer connection logic #1008
server: fix inbound/outbound peer connection logic #1008
Conversation
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.
utACK.
Know @cfromknecht had some insights into this.
cACK for now, gonna run this on testnet for a bit to make sure the issues from before don't resurface. My current reasoning that this wasn't working in the past because the persistent connection requests weren't being canceled, causing this to end up in a weird state or flap unnecessarily. |
c9d74f1
to
2762e17
Compare
server.go
Outdated
@@ -1368,7 +1369,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, | |||
|
|||
// We'll ensure that we locate the proper port to use within the peer's | |||
// address for reconnecting purposes. | |||
if tcpAddr, ok := addr.(*net.TCPAddr); ok && !inbound { | |||
if tcpAddr, ok := addr.(*net.TCPAddr); ok && inbound { |
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.
Rebased this to include a recent change that depends on the flipped behavior.
2762e17
to
9c6711b
Compare
Aight, been seeing some errors that may be attributed to this issue, time to revive. Gonna some more testing with this on current master |
Can you rebase this? Thanks! |
9c6711b
to
f7002cf
Compare
In this commit, we address the meaning of the inbound parameter to peerConnected. An inbound connection is defined as a connection initiated by the peer, rather than ourselves. We also update the inbound value for the peerConnected calls within OutboundPeerConnected and InboundPeerConnected to reflect the definition above.
This reverts commit 5126e43 since the underlying issue has now been fixed.
f7002cf
to
077b1ff
Compare
Rebased. |
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.
LGTM 🏄🏾
This PR attempts to fix a small bug where inbound peers were being tracked as outbound and outbound as inbound.
I went through the rest of the connection logic and our uses of inbound/outbound connections seem to be consistent with their respective meanings. Inbound connections should be connections initiated by the remote peer, while outbound connections should be initiated locally.
I believe the small patch below should be enough to remedy this issue, although I might have missed something.
Fixes #997.