Skip to content

Commit

Permalink
Merge branch 'master' into fix-healthrecord-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianMincu authored Sep 28, 2021
2 parents 1fa2ce6 + b11336f commit 4ee90b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func main() {

err := app.Run(os.Args)
if err != nil {
log.Error(err.Error())
os.Exit(1)
}
}
Expand Down
22 changes: 18 additions & 4 deletions p2p/libp2p/discovery/continuousKadDhtDiscoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package discovery

import (
"context"
"errors"
"fmt"
"sync"
"time"
Expand Down Expand Up @@ -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 {
Expand All @@ -253,6 +251,22 @@ func (ckdd *ContinuousKadDhtDiscoverer) tryConnectToSeeder(
chanDone <- struct{}{}
}

func printConnectionErrorToSeeder(peer string, err error) {
if errors.Is(err, p2p.ErrUnwantedPeer) {
log.Trace("tryConnectToSeeder: unwanted peer",
"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
Expand Down
2 changes: 1 addition & 1 deletion p2p/libp2p/discovery/optimizedKadDhtDiscoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4ee90b9

Please sign in to comment.