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:
1 file changed
+6
-1
@@ -138,7 +138,7 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
|
|||||||
sendRequests: make(chan *sendReq),
|
sendRequests: make(chan *sendReq),
|
||||||
|
|
||||||
globalFeatures: globalFeatures,
|
globalFeatures: globalFeatures,
|
||||||
localFeatures: localFeatures,
|
localFeatures: localFeatures,
|
||||||
|
|
||||||
queries: make(chan interface{}),
|
queries: make(chan interface{}),
|
||||||
quit: make(chan struct{}),
|
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)
|
peer, err := newPeer(conn, s, peerAddr, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Errorf("unable to create peer %v", err)
|
srvrLog.Errorf("unable to create peer %v", err)
|
||||||
|
s.connMgr.Remove(peer.connReq.ID())
|
||||||
|
peer.Disconnect()
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
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?
|
// * also mark last-seen, do it one single transaction?
|
||||||
|
|
||||||
if err := peer.Start(); err != nil {
|
if err := peer.Start(); err != nil {
|
||||||
|
srvrLog.Errorf("unable to start peer: %v", err)
|
||||||
|
s.connMgr.Remove(peer.connReq.ID())
|
||||||
|
peer.Disconnect()
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user