提交 67a6b145 作者: vyzo 提交者: Steven Allen

remove host parameter from StartOnlineServicesWithHost

PeerHost is now initialized before calling it.

License: MIT
Signed-off-by: 's avatarvyzo <vyzo@hackzen.org>
上级 30e4cc9d
...@@ -281,7 +281,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin ...@@ -281,7 +281,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
n.PeerHost = peerhost n.PeerHost = peerhost
if err := n.startOnlineServicesWithHost(ctx, peerhost, routingOption, pubsub, ipnsps); err != nil { if err := n.startOnlineServicesWithHost(ctx, routingOption, pubsub, ipnsps); err != nil {
return err return err
} }
...@@ -475,7 +475,7 @@ func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) { ...@@ -475,7 +475,7 @@ func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) {
// startOnlineServicesWithHost is the set of services which need to be // startOnlineServicesWithHost is the set of services which need to be
// initialized with the host and _before_ we start listening. // initialized with the host and _before_ we start listening.
func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost.Host, routingOption RoutingOption, enablePubsub bool, enableIpnsps bool) error { func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, routingOption RoutingOption, enablePubsub bool, enableIpnsps bool) error {
cfg, err := n.Repo.Config() cfg, err := n.Repo.Config()
if err != nil { if err != nil {
return err return err
...@@ -487,7 +487,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost ...@@ -487,7 +487,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
opts = append(opts, libp2p.DefaultTransports, libp2p.Transport(quic.NewTransport)) opts = append(opts, libp2p.DefaultTransports, libp2p.Transport(quic.NewTransport))
} }
svc, err := autonat.NewAutoNATService(ctx, host, opts...) svc, err := autonat.NewAutoNATService(ctx, n.PeerHost, opts...)
if err != nil { if err != nil {
return err return err
} }
...@@ -510,10 +510,10 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost ...@@ -510,10 +510,10 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
case "": case "":
fallthrough fallthrough
case "floodsub": case "floodsub":
service, err = pubsub.NewFloodSub(ctx, host, pubsubOptions...) service, err = pubsub.NewFloodSub(ctx, n.PeerHost, pubsubOptions...)
case "gossipsub": case "gossipsub":
service, err = pubsub.NewGossipSub(ctx, host, pubsubOptions...) service, err = pubsub.NewGossipSub(ctx, n.PeerHost, pubsubOptions...)
default: default:
err = fmt.Errorf("Unknown pubsub router %s", cfg.Pubsub.Router) err = fmt.Errorf("Unknown pubsub router %s", cfg.Pubsub.Router)
...@@ -525,15 +525,15 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost ...@@ -525,15 +525,15 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
n.PubSub = service n.PubSub = service
} }
// this code is necessary as the host is necessary for tests: mock network constructions // this code is necessary just for tests: mock network constructions
// ignore the libp2p options that actually construct the routing! // ignore the libp2p constructor options that actually construct the routing!
if n.Routing == nil { if n.Routing == nil {
r, err := routingOption(ctx, host, n.Repo.Datastore(), n.RecordValidator) r, err := routingOption(ctx, n.PeerHost, n.Repo.Datastore(), n.RecordValidator)
if err != nil { if err != nil {
return err return err
} }
n.Routing = r n.Routing = r
n.PeerHost = rhost.Wrap(host, n.Routing) n.PeerHost = rhost.Wrap(n.PeerHost, n.Routing)
} }
// TODO: I'm not a fan of type assertions like this but the // TODO: I'm not a fan of type assertions like this but the
...@@ -556,7 +556,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost ...@@ -556,7 +556,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
if enableIpnsps { if enableIpnsps {
n.PSRouter = psrouter.NewPubsubValueStore( n.PSRouter = psrouter.NewPubsubValueStore(
ctx, ctx,
host, n.PeerHost,
n.Routing, n.Routing,
n.PubSub, n.PubSub,
n.RecordValidator, n.RecordValidator,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论