-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Reconnect to peer when switching networks #2058
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2124,13 +2124,13 @@ func (s *server) InboundPeerConnected(conn net.Conn) { | |
|
|
||
| case nil: | ||
| // We already have a connection with the incoming peer. If the | ||
| // connection we've already established should be kept, then | ||
| // we'll close out this connection s.t there's only a single | ||
| // connection between us. | ||
| // connection we've already established should be kept and is not of | ||
| // the same type of the new connection (inbound), then we'll close out | ||
| // the new connection s.t there's only a single connection between us. | ||
| localPub := s.identityPriv.PubKey() | ||
| if !shouldDropLocalConnection(localPub, nodePub) { | ||
| srvrLog.Warnf("Received inbound connection from "+ | ||
| "peer %x, but already connected, dropping conn", | ||
| if !connectedPeer.inbound && !shouldDropLocalConnection(localPub, nodePub) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comments here and below no longer match the rationale behind the logic.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the comments to be more specific and to contain description for the additional logic. |
||
| srvrLog.Warnf("Received inbound connection from peer %x, "+ | ||
| "but already have outbound connection, dropping conn", | ||
| nodePub.SerializeCompressed()) | ||
| conn.Close() | ||
| return | ||
|
|
@@ -2230,14 +2230,14 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn) | |
| s.peerConnected(conn, connReq, false) | ||
|
|
||
| case nil: | ||
| // We already have a connection open with the target peer. | ||
| // If our (this) connection should be dropped, then we'll do | ||
| // so, in order to ensure we don't have any duplicate | ||
| // connections. | ||
| // We already have a connection with the incoming peer. If the | ||
| // connection we've already established should be kept and is not of | ||
| // the same type of the new connection (outbound), then we'll close out | ||
| // the new connection s.t there's only a single connection between us. | ||
| localPub := s.identityPriv.PubKey() | ||
| if shouldDropLocalConnection(localPub, nodePub) { | ||
| srvrLog.Warnf("Established outbound connection to "+ | ||
| "peer %x, but already connected, dropping conn", | ||
| if connectedPeer.inbound && shouldDropLocalConnection(localPub, nodePub) { | ||
| srvrLog.Warnf("Established outbound connection to peer %x, "+ | ||
| "but already have inbound connection, dropping conn", | ||
| nodePub.SerializeCompressed()) | ||
| if connReq != nil { | ||
| s.connMgr.Remove(connReq.ID()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.