diff --git a/pkg/config/config.go b/pkg/config/config.go index 404a31ed21..3423e3021a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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") diff --git a/pkg/transport/libp2p/libp2p.go b/pkg/transport/libp2p/libp2p.go index b682c2d97c..e05c29799f 100644 --- a/pkg/transport/libp2p/libp2p.go +++ b/pkg/transport/libp2p/libp2p.go @@ -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 @@ -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 }