2019-07-02 12:40:25 +00:00
|
|
|
package lp2p
|
2019-07-01 09:09:48 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
host "github.com/libp2p/go-libp2p-core/host"
|
|
|
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
2019-07-01 09:09:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func FloodSub(pubsubOptions ...pubsub.Option) interface{} {
|
|
|
|
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) (service *pubsub.PubSub, err error) {
|
|
|
|
return pubsub.NewFloodSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GossipSub(pubsubOptions ...pubsub.Option) interface{} {
|
|
|
|
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) (service *pubsub.PubSub, err error) {
|
|
|
|
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...)
|
|
|
|
}
|
|
|
|
}
|