From 163d90c8664670a63a9dd36614335f5e55edad4e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 18 Jan 2021 21:10:06 +0300 Subject: [PATCH] network: don't register addresses before version handshake 1) It duplicates registration in `version` message handler and no valid connection can work without version exchange. 2) On public networks we have seed nodes defined by names, so we register connections to them using these names, but then if connection is dropped we delist them by IP:PORT combinations which can lead to zero PeerCount() with all seeds still being registered as connected in the discovery subsystem and thus no reconnection attempts being made. --- pkg/network/discovery.go | 2 -- pkg/network/discovery_test.go | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/network/discovery.go b/pkg/network/discovery.go index c9e8dc49c..9d7073226 100644 --- a/pkg/network/discovery.go +++ b/pkg/network/discovery.go @@ -192,8 +192,6 @@ func (d *DefaultDiscovery) tryAddress(addr string) { if err := d.transport.Dial(addr, d.dialTimeout); err != nil { d.RegisterBadAddr(addr) d.RequestRemote(1) - } else { - d.RegisterConnectedAddr(addr) } } diff --git a/pkg/network/discovery_test.go b/pkg/network/discovery_test.go index dc69d3d7b..9c8fb1aad 100644 --- a/pkg/network/discovery_test.go +++ b/pkg/network/discovery_test.go @@ -81,6 +81,7 @@ func TestDefaultDiscoverer(t *testing.T) { select { case a := <-ts.dialCh: dialled = append(dialled, a) + d.RegisterConnectedAddr(a) case <-time.After(time.Second): t.Fatalf("timeout expecting for transport dial") }