Merge pull request #2058 from roeierez/fix_reconnect
Reconnect to peer when switching networks
This commit is contained in:
commit
1a8e4b0316
26
server.go
26
server.go
@ -2156,13 +2156,13 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
|||||||
|
|
||||||
case nil:
|
case nil:
|
||||||
// We already have a connection with the incoming peer. If the
|
// We already have a connection with the incoming peer. If the
|
||||||
// connection we've already established should be kept, then
|
// connection we've already established should be kept and is not of
|
||||||
// we'll close out this connection s.t there's only a single
|
// the same type of the new connection (inbound), then we'll close out
|
||||||
// connection between us.
|
// the new connection s.t there's only a single connection between us.
|
||||||
localPub := s.identityPriv.PubKey()
|
localPub := s.identityPriv.PubKey()
|
||||||
if !shouldDropLocalConnection(localPub, nodePub) {
|
if !connectedPeer.inbound && !shouldDropLocalConnection(localPub, nodePub) {
|
||||||
srvrLog.Warnf("Received inbound connection from "+
|
srvrLog.Warnf("Received inbound connection from peer %x, "+
|
||||||
"peer %x, but already connected, dropping conn",
|
"but already have outbound connection, dropping conn",
|
||||||
nodePub.SerializeCompressed())
|
nodePub.SerializeCompressed())
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
@ -2262,14 +2262,14 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
|||||||
s.peerConnected(conn, connReq, false)
|
s.peerConnected(conn, connReq, false)
|
||||||
|
|
||||||
case nil:
|
case nil:
|
||||||
// We already have a connection open with the target peer.
|
// We already have a connection with the incoming peer. If the
|
||||||
// If our (this) connection should be dropped, then we'll do
|
// connection we've already established should be kept and is not of
|
||||||
// so, in order to ensure we don't have any duplicate
|
// the same type of the new connection (outbound), then we'll close out
|
||||||
// connections.
|
// the new connection s.t there's only a single connection between us.
|
||||||
localPub := s.identityPriv.PubKey()
|
localPub := s.identityPriv.PubKey()
|
||||||
if shouldDropLocalConnection(localPub, nodePub) {
|
if connectedPeer.inbound && shouldDropLocalConnection(localPub, nodePub) {
|
||||||
srvrLog.Warnf("Established outbound connection to "+
|
srvrLog.Warnf("Established outbound connection to peer %x, "+
|
||||||
"peer %x, but already connected, dropping conn",
|
"but already have inbound connection, dropping conn",
|
||||||
nodePub.SerializeCompressed())
|
nodePub.SerializeCompressed())
|
||||||
if connReq != nil {
|
if connReq != nil {
|
||||||
s.connMgr.Remove(connReq.ID())
|
s.connMgr.Remove(connReq.ID())
|
||||||
|
Loading…
Reference in New Issue
Block a user