mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
27 lines
909 B
Go
27 lines
909 B
Go
package libp2p
|
|
|
|
import (
|
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
|
"github.com/libp2p/go-libp2p/core/discovery"
|
|
"github.com/libp2p/go-libp2p/core/host"
|
|
"go.uber.org/fx"
|
|
|
|
"github.com/ipfs/kubo/core/node/helpers"
|
|
)
|
|
|
|
func FloodSub(pubsubOptions ...pubsub.Option) interface{} {
|
|
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, disc discovery.Discovery) (service *pubsub.PubSub, err error) {
|
|
return pubsub.NewFloodSub(helpers.LifecycleCtx(mctx, lc), host, append(pubsubOptions, pubsub.WithDiscovery(disc))...)
|
|
}
|
|
}
|
|
|
|
func GossipSub(pubsubOptions ...pubsub.Option) interface{} {
|
|
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, disc discovery.Discovery) (service *pubsub.PubSub, err error) {
|
|
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, append(
|
|
pubsubOptions,
|
|
pubsub.WithDiscovery(disc),
|
|
pubsub.WithFloodPublish(true))...,
|
|
)
|
|
}
|
|
}
|