lotus/node/modules/lp2p/relay.go
Masih H. Derkani 39a710e1d6 Address lint issues as a result of libp2p deprecations and tidy go mod
Address staticcheck issues caused by deprecated APIs and `go mod tidy`.
2022-06-29 14:55:35 -04:00

29 lines
774 B
Go

package lp2p
import (
"fmt"
"github.com/libp2p/go-libp2p"
coredisc "github.com/libp2p/go-libp2p-core/discovery"
"github.com/libp2p/go-libp2p-core/routing"
routingdisc "github.com/libp2p/go-libp2p/p2p/discovery/routing"
)
func NoRelay() func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
// always disabled, it's an eclipse attack vector
opts.Opts = append(opts.Opts, libp2p.DisableRelay())
return
}
}
// TODO: should be use baseRouting or can we use higher level router here?
func Discovery(router BaseIpfsRouting) (coredisc.Discovery, error) {
crouter, ok := router.(routing.ContentRouting)
if !ok {
return nil, fmt.Errorf("no suitable routing for discovery")
}
return routingdisc.NewRoutingDiscovery(crouter), nil
}