Skip to content

Commit

Permalink
Merge pull request #938 from filecoin-project/fix-disconnected-network
Browse files Browse the repository at this point in the history
Fix disconnected network
  • Loading branch information
binocarlos authored Oct 24, 2022
2 parents d634846 + 2fad44b commit ad2671e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ func SetDownloadURLRequestRetries(count int) {
downloadURLRequestRetries = count
}

func GetLibp2pTracerPath() string {
configPath := GetConfigPath()
return filepath.Join(configPath, "bacalhau-libp2p-tracer.json")
}

func GetConfigPath() string {
suffix := "/.bacalhau"
env := os.Getenv("BACALHAU_PATH")
Expand Down
14 changes: 13 additions & 1 deletion pkg/transport/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func NewTransportFromOptions(ctx context.Context,
return nil
})

tracer, err := pubsub.NewJSONTracer(config.GetLibp2pTracerPath())
if err != nil {
return nil, err
}

h, err := libp2p.New(opts...)
if err != nil {
return nil, err
Expand All @@ -92,7 +97,14 @@ func NewTransportFromOptions(ctx context.Context,
pubsub.ScoreParameterDecay(2*time.Minute), //nolint:gomnd
pubsub.ScoreParameterDecay(10*time.Minute), //nolint:gomnd
)
ps, err := pubsub.NewGossipSub(ctx, h, pubsub.WithPeerExchange(true), pubsub.WithPeerGater(pgParams))
ps, err := pubsub.NewGossipSub(
ctx,
h,
pubsub.WithFloodPublish(true),
pubsub.WithPeerExchange(true),
pubsub.WithPeerGater(pgParams),
pubsub.WithEventTracer(tracer),
)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ad2671e

Please sign in to comment.