server: ensure we don't auto-connect to peers we're unable to create/start
This commit prevent unnecessary connection flapping by ensure we don’t attempt to auto-connect to a peer that we’re unable to create or start the goroutines of. With this commit, we won’t attempt to auto-connect to a peer that has incompatible feature sets to that of ours.
This commit is contained in:
parent
ae15a193e2
commit
0bbb072ceb
@ -138,7 +138,7 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
|
||||
sendRequests: make(chan *sendReq),
|
||||
|
||||
globalFeatures: globalFeatures,
|
||||
localFeatures: localFeatures,
|
||||
localFeatures: localFeatures,
|
||||
|
||||
queries: make(chan interface{}),
|
||||
quit: make(chan struct{}),
|
||||
@ -414,6 +414,8 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, inbound
|
||||
peer, err := newPeer(conn, s, peerAddr, false)
|
||||
if err != nil {
|
||||
srvrLog.Errorf("unable to create peer %v", err)
|
||||
s.connMgr.Remove(peer.connReq.ID())
|
||||
peer.Disconnect()
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
@ -425,6 +427,9 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, inbound
|
||||
// * also mark last-seen, do it one single transaction?
|
||||
|
||||
if err := peer.Start(); err != nil {
|
||||
srvrLog.Errorf("unable to start peer: %v", err)
|
||||
s.connMgr.Remove(peer.connReq.ID())
|
||||
peer.Disconnect()
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user