network: don't reconnect to peers with identical ID

This commit is contained in:
Evgenii Stratonikov 2019-11-27 11:56:56 +03:00
parent fdd5276d3e
commit b5fb43bac9

View file

@ -235,8 +235,12 @@ func (s *Server) run() {
"peerCount": s.PeerCount(),
}).Warn("peer disconnected")
addr := drop.peer.PeerAddr().String()
s.discovery.UnregisterConnectedAddr(addr)
s.discovery.BackFill(addr)
if drop.reason == errIdenticalID {
s.discovery.RegisterBadAddr(addr)
} else {
s.discovery.UnregisterConnectedAddr(addr)
s.discovery.BackFill(addr)
}
updatePeersConnectedMetric(s.PeerCount())
} else {
// else the peer is already gone, which can happen