Merge pull request #433 from cfromknecht/persistent-conn-mgr

Improve Consistency of Logging and Actions in peerTerminationWatcher
This commit is contained in:
Olaoluwa Osuntokun 2017-12-13 15:54:58 -08:00 committed by GitHub
commit 394183040c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -364,7 +364,6 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
OnAccept: s.InboundPeerConnected,
RetryDuration: time.Second * 5,
TargetOutbound: 100,
GetNewAddress: nil,
Dial: noiseDial(s.identityPriv),
OnConnection: s.OutboundPeerConnected,
})
@ -1087,6 +1086,12 @@ func (s *server) peerTerminationWatcher(p *peer) {
pubStr := string(p.addr.IdentityKey.SerializeCompressed())
_, ok := s.persistentPeers[pubStr]
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 "+
"connection to peer %v", p)
@ -1098,12 +1103,6 @@ func (s *server) peerTerminationWatcher(p *peer) {
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
// to attempt to maintain a persistent connection with this
// peer.