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 ...@@ -35,12 +35,7 @@ type AddrsFactory = bhost.AddrsFactory
// NATManagerC is a NATManager constructor. // NATManagerC is a NATManager constructor.
type NATManagerC func(inet.Network) bhost.NATManager type NATManagerC func(inet.Network) bhost.NATManager
type BasicRouting interface { type RoutingC func(host.Host) (routing.PeerRouting, error)
routing.ContentRouting
routing.PeerRouting
}
type RoutingC func(host.Host) (BasicRouting, error)
// Config describes a set of settings for a libp2p node // Config describes a set of settings for a libp2p node
// //
...@@ -178,8 +173,10 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) { ...@@ -178,8 +173,10 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
return nil, err return nil, err
} }
crouter, ok := router.(routing.ContentRouting)
if ok {
if cfg.Relay { if cfg.Relay {
discovery := discovery.NewRoutingDiscovery(router) discovery := discovery.NewRoutingDiscovery(crouter)
hop := false hop := false
for _, opt := range cfg.RelayOpts { for _, opt := range cfg.RelayOpts {
...@@ -195,6 +192,7 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) { ...@@ -195,6 +192,7 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
h = relay.NewAutoRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery) h = relay.NewAutoRelayHost(swrm.Context(), h.(*bhost.BasicHost), discovery)
} }
} }
}
h = routed.Wrap(h, router) h = routed.Wrap(h, router)
} }
......
...@@ -15,9 +15,6 @@ type Config = config.Config ...@@ -15,9 +15,6 @@ type Config = config.Config
// (`libp2p.New`). // (`libp2p.New`).
type Option = config.Option type Option = config.Option
// BasicRouting is the combination of PeerRouting and ContentRouting
type BasicRouting = config.BasicRouting
// ChainOptions chains multiple options into a single option. // ChainOptions chains multiple options into a single option.
func ChainOptions(opts ...Option) Option { func ChainOptions(opts ...Option) Option {
return func(cfg *Config) error { return func(cfg *Config) error {
......
...@@ -136,7 +136,7 @@ func TestAutoRelay(t *testing.T) { ...@@ -136,7 +136,7 @@ func TestAutoRelay(t *testing.T) {
defer cancel() defer cancel()
mtab := newMockRoutingTable() mtab := newMockRoutingTable()
makeRouting := func(h host.Host) (libp2p.BasicRouting, error) { makeRouting := func(h host.Host) (routing.PeerRouting, error) {
mr := newMockRouting(h, mtab) mr := newMockRouting(h, mtab)
return mr, nil 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