server: reorder short-circuit in peer termination watcher
This commit reorders logic in the peer termination watcher such that we short circuit earlier if we already have pending persistent connection requests. Before, the debug statement may have indicated that a reconnection was being attempted, even though it may have exited before submitting the request to the connection manager.
This commit is contained in:
parent
26ec569fca
commit
9713cd81fc
13
server.go
13
server.go
@ -364,7 +364,6 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
|||||||
OnAccept: s.InboundPeerConnected,
|
OnAccept: s.InboundPeerConnected,
|
||||||
RetryDuration: time.Second * 5,
|
RetryDuration: time.Second * 5,
|
||||||
TargetOutbound: 100,
|
TargetOutbound: 100,
|
||||||
GetNewAddress: nil,
|
|
||||||
Dial: noiseDial(s.identityPriv),
|
Dial: noiseDial(s.identityPriv),
|
||||||
OnConnection: s.OutboundPeerConnected,
|
OnConnection: s.OutboundPeerConnected,
|
||||||
})
|
})
|
||||||
@ -1087,6 +1086,12 @@ func (s *server) peerTerminationWatcher(p *peer) {
|
|||||||
pubStr := string(p.addr.IdentityKey.SerializeCompressed())
|
pubStr := string(p.addr.IdentityKey.SerializeCompressed())
|
||||||
_, ok := s.persistentPeers[pubStr]
|
_, ok := s.persistentPeers[pubStr]
|
||||||
if ok {
|
if ok {
|
||||||
|
// We'll only need to re-launch a connection request if one
|
||||||
|
// isn't already currently pending.
|
||||||
|
if _, ok := s.persistentConnReqs[pubStr]; ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
srvrLog.Debugf("Attempting to re-establish persistent "+
|
srvrLog.Debugf("Attempting to re-establish persistent "+
|
||||||
"connection to peer %v", p)
|
"connection to peer %v", p)
|
||||||
|
|
||||||
@ -1098,12 +1103,6 @@ func (s *server) peerTerminationWatcher(p *peer) {
|
|||||||
Permanent: true,
|
Permanent: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll only need to re-launch a connection requests if one
|
|
||||||
// isn't already currently pending.
|
|
||||||
if _, ok := s.persistentConnReqs[pubStr]; ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, we'll launch a new connection requests in order
|
// Otherwise, we'll launch a new connection requests in order
|
||||||
// to attempt to maintain a persistent connection with this
|
// to attempt to maintain a persistent connection with this
|
||||||
// peer.
|
// peer.
|
||||||
|
Loading…
Reference in New Issue
Block a user