From 96560e05b9779f70198605e7ccf4fca886c32eb3 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Tue, 28 Sep 2021 13:26:19 +0300 Subject: [PATCH 1/3] - fixed connect to seeders print --- .../discovery/continuousKadDhtDiscoverer.go | 22 +++++++++++++++---- .../discovery/optimizedKadDhtDiscoverer.go | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go b/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go index 723f78de8b8..b8140758ad0 100644 --- a/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go +++ b/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go @@ -2,6 +2,7 @@ package discovery import ( "context" + "errors" "fmt" "sync" "time" @@ -231,10 +232,7 @@ func (ckdd *ContinuousKadDhtDiscoverer) tryConnectToSeeder( initialPeer := initialPeersList[startIndex] err := ckdd.host.ConnectToPeer(ckdd.context, initialPeer) if err != nil { - log.Debug("error connecting to seeder", - "seeder", initialPeer, - "error", err.Error(), - ) + printConnectionErrorToSeeder(initialPeer, err) startIndex++ startIndex = startIndex % len(initialPeersList) select { @@ -253,6 +251,22 @@ func (ckdd *ContinuousKadDhtDiscoverer) tryConnectToSeeder( chanDone <- struct{}{} } +func printConnectionErrorToSeeder(peer string, err error) { + if errors.Is(err, p2p.ErrUnwantedPeer) { + log.Trace("error connecting to seeder", + "seeder", peer, + "error", err.Error(), + ) + + return + } + + log.Debug("error connecting to seeder", + "seeder", peer, + "error", err.Error(), + ) +} + // Name returns the name of the kad dht peer discovery implementation func (ckdd *ContinuousKadDhtDiscoverer) Name() string { return kadDhtName diff --git a/p2p/libp2p/discovery/optimizedKadDhtDiscoverer.go b/p2p/libp2p/discovery/optimizedKadDhtDiscoverer.go index 2b3718b2457..09df8b03b5c 100644 --- a/p2p/libp2p/discovery/optimizedKadDhtDiscoverer.go +++ b/p2p/libp2p/discovery/optimizedKadDhtDiscoverer.go @@ -180,7 +180,7 @@ func (okdd *optimizedKadDhtDiscoverer) tryToReconnectAtLeastToASeeder(ctx contex for _, seederAddress := range okdd.initialPeersList { err := okdd.connectToSeeder(ctx, seederAddress) if err != nil { - log.Debug("error connecting to seeder", "seeder", seederAddress, "error", err.Error()) + printConnectionErrorToSeeder(seederAddress, err) } else { connectedToOneSeeder = true } From 93e98a1596e75389c66323938adbf4400f80ee56 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Tue, 28 Sep 2021 13:36:21 +0300 Subject: [PATCH 2/3] - added missing log print on node start error --- cmd/node/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/node/main.go b/cmd/node/main.go index 1b042bd55ee..34e971334d9 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -74,6 +74,7 @@ func main() { err := app.Run(os.Args) if err != nil { + log.Error(err.Error()) os.Exit(1) } } From 78cd5004628b5d1dc10dbdee60c964d4835d0224 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Tue, 28 Sep 2021 13:38:31 +0300 Subject: [PATCH 3/3] - changed print --- p2p/libp2p/discovery/continuousKadDhtDiscoverer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go b/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go index b8140758ad0..f361fdd97f8 100644 --- a/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go +++ b/p2p/libp2p/discovery/continuousKadDhtDiscoverer.go @@ -253,7 +253,7 @@ func (ckdd *ContinuousKadDhtDiscoverer) tryConnectToSeeder( func printConnectionErrorToSeeder(peer string, err error) { if errors.Is(err, p2p.ErrUnwantedPeer) { - log.Trace("error connecting to seeder", + log.Trace("tryConnectToSeeder: unwanted peer", "seeder", peer, "error", err.Error(), )