mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
network: allow discoverer to reuse addresses
...and don't try to connect to the nodes we're already connected to. Before this change we had a problem of discoverer throwing away good valid addresses just because they are already known which lead to pool draining over time (as address reuse was basically forbidden and getaddr may not get enough new nodes).
This commit is contained in:
parent
46dc141c6c
commit
773ccc2b92
3 changed files with 62 additions and 16 deletions
|
@ -160,7 +160,9 @@ func (s *Server) run() {
|
|||
"reason": drop.reason,
|
||||
"peerCount": s.PeerCount(),
|
||||
}).Warn("peer disconnected")
|
||||
s.discovery.BackFill(drop.peer.NetAddr().String())
|
||||
addr := drop.peer.NetAddr().String()
|
||||
s.discovery.UnregisterConnectedAddr(addr)
|
||||
s.discovery.BackFill(addr)
|
||||
}
|
||||
// else the peer is already gone, which can happen
|
||||
// because we have two goroutines sending signals here
|
||||
|
@ -191,6 +193,7 @@ func (s *Server) startProtocol(p Peer) {
|
|||
"id": p.Version().Nonce,
|
||||
}).Info("started protocol")
|
||||
|
||||
s.discovery.RegisterGoodAddr(p.NetAddr().String())
|
||||
err := s.requestHeaders(p)
|
||||
if err != nil {
|
||||
p.Disconnect(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue