diff --git a/config/config.go b/config/config.go index 3d06fdca0a53808e9db12011842e7a0c1f7af33f..c503509465e27494564dcc2d84f59dd731e7ffe8 100644 --- a/config/config.go +++ b/config/config.go @@ -35,12 +35,7 @@ type AddrsFactory = bhost.AddrsFactory // NATManagerC is a NATManager constructor. type NATManagerC func(inet.Network) bhost.NATManager -type BasicRouting interface { - routing.ContentRouting - routing.PeerRouting -} - -type RoutingC func(host.Host) (BasicRouting, error) +type RoutingC func(host.Host) (routing.PeerRouting, error) // Config describes a set of settings for a libp2p node // @@ -178,21 +173,24 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) { return nil, err } - if cfg.Relay { - discovery := discovery.NewRoutingDiscovery(router) - - hop := false - for _, opt := range cfg.RelayOpts { - if opt == circuit.OptHop { - hop = true - break + crouter, ok := router.(routing.ContentRouting) + if ok { + if cfg.Relay { + discovery := discovery.NewRoutingDiscovery(crouter) + + hop := false + for _, opt := range cfg.RelayOpts { + if opt == circuit.OptHop { + hop = true + break + } } - } - if hop { - h = relay.NewRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery) - } else { - h = relay.NewAutoRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery) + if hop { + h = relay.NewRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery) + } else { + h = relay.NewAutoRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery) + } } } diff --git a/libp2p.go b/libp2p.go index 6c928c31595259ea0b1809351b21f789878b928f..ad026ad4bd8439099b78ed749af57cab2baccf1c 100644 --- a/libp2p.go +++ b/libp2p.go @@ -15,9 +15,6 @@ type Config = config.Config // (`libp2p.New`). type Option = config.Option -// BasicRouting is the combination of PeerRouting and ContentRouting -type BasicRouting = config.BasicRouting - // ChainOptions chains multiple options into a single option. func ChainOptions(opts ...Option) Option { return func(cfg *Config) error { diff --git a/p2p/host/relay/autorelay_test.go b/p2p/host/relay/autorelay_test.go index 241e33f65e3d7b12865c013be554eaaeeea27512..a3ac7dd2954d32336855f1ab98a3011c8bbf7881 100644 --- a/p2p/host/relay/autorelay_test.go +++ b/p2p/host/relay/autorelay_test.go @@ -136,7 +136,7 @@ func TestAutoRelay(t *testing.T) { defer cancel() mtab := newMockRoutingTable() - makeRouting := func(h host.Host) (libp2p.BasicRouting, error) { + makeRouting := func(h host.Host) (routing.PeerRouting, error) { mr := newMockRouting(h, mtab) return mr, nil }