Commit 7b324b14 authored by vyzo's avatar vyzo
Browse files

remove BasicRouting interface; use PeerRouting and upcast for discovery

parent c2d846a7
......@@ -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,8 +173,10 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
return nil, err
}
crouter, ok := router.(routing.ContentRouting)
if ok {
if cfg.Relay {
discovery := discovery.NewRoutingDiscovery(router)
discovery := discovery.NewRoutingDiscovery(crouter)
hop := false
for _, opt := range cfg.RelayOpts {
......@@ -195,6 +192,7 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
h = relay.NewAutoRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery)
}
}
}
h = routed.Wrap(h, router)
}
......
......@@ -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 {
......
......@@ -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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment