explicitly enable autorelay
License: MIT Signed-off-by: vyzo <vyzo@hackzen.org>
vyzo committed
Dec 11, 2018 at 11:55 UTC
30e4cc9d9152c3a2b9b8a94b977215a1e91f82f4
1 file changed
+11
-10
core/core.go
+11
-10
@@ -261,13 +261,16 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
261
libp2pOpts = append(libp2pOpts, libp2p.Transport(quic.NewTransport))
262
}
263
264
- // enable routing and autorelay
264
+ // enable routing
265
+ libp2pOpts = append(libp2pOpts, libp2p.Routing(func(h p2phost.Host) (routing.PeerRouting, error) {
266
+ r, err := routingOption(ctx, h, n.Repo.Datastore(), n.RecordValidator)
267
+ n.Routing = r
268
+ return r, err
269
+ }))
270
+
271
+ // enable autorelay
272
if cfg.Swarm.EnableAutoRelay {
266
- libp2pOpts = append(libp2pOpts, libp2p.Routing(func(h p2phost.Host) (routing.PeerRouting, error) {
267
- r, err := routingOption(ctx, h, n.Repo.Datastore(), n.RecordValidator)
268
- n.Routing = r
269
- return r, err
270
- }))
273
+ libp2pOpts = append(libp2pOpts, libp2p.EnableAutoRelay())
274
}
275
276
peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, libp2pOpts...)
@@ -522,10 +525,8 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
525
n.PubSub = service
526
}
527
525
- // this code is necessary as the host is constructed with routing only if autorelay
526
- // is enabled.
527
- // it is also necessary for tests: mock network constructions ignore the libp2p options
528
- // that actually construct the routing!
528
+ // this code is necessary as the host is necessary for tests: mock network constructions
529
+ // ignore the libp2p options that actually construct the routing!
530
if n.Routing == nil {
531
r, err := routingOption(ctx, host, n.Repo.Datastore(), n.RecordValidator)
532
if err != nil {