@cryptotaxi247 / kubo / commits / da473d286

constructor: move libp2p related stuff to subpackage

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Apr 23, 2019 at 12:35 UTC da473d286fd8a7e96093e451fdc8acceba18b583
13 files changed +115 -97
cmd/ipfs/daemon.go
+4 -4
@@ -20,7 +20,7 @@ import (
20 coreapi "github.com/ipfs/go-ipfs/core/coreapi"
21 corehttp "github.com/ipfs/go-ipfs/core/corehttp"
22 corerepo "github.com/ipfs/go-ipfs/core/corerepo"
23 - "github.com/ipfs/go-ipfs/core/node"
23 + libp2p "github.com/ipfs/go-ipfs/core/node/libp2p"
24 nodeMount "github.com/ipfs/go-ipfs/fuse/node"
25 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
26 migrate "github.com/ipfs/go-ipfs/repo/fsrepo/migrations"
@@ -324,11 +324,11 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
324 case routingOptionSupernodeKwd:
325 return errors.New("supernode routing was never fully implemented and has been removed")
326 case routingOptionDHTClientKwd:
327 - ncfg.Routing = node.DHTClientOption
327 + ncfg.Routing = libp2p.DHTClientOption
328 case routingOptionDHTKwd:
329 - ncfg.Routing = node.DHTOption
329 + ncfg.Routing = libp2p.DHTOption
330 case routingOptionNoneKwd:
331 - ncfg.Routing = node.NilRouterOption
331 + ncfg.Routing = libp2p.NilRouterOption
332 default:
333 return fmt.Errorf("unrecognized routing option: %s", routingOption)
334 }
core/core.go
+5 -4
@@ -18,6 +18,7 @@ import (
18 version "github.com/ipfs/go-ipfs"
19 "github.com/ipfs/go-ipfs/core/bootstrap"
20 "github.com/ipfs/go-ipfs/core/node"
21 + "github.com/ipfs/go-ipfs/core/node/libp2p"
22 rp "github.com/ipfs/go-ipfs/exchange/reprovide"
23 "github.com/ipfs/go-ipfs/filestore"
24 "github.com/ipfs/go-ipfs/fuse/mount"
@@ -68,10 +69,10 @@ type IpfsNode struct {
69 Repo repo.Repo
70
71 // Local node
71 - Pinning pin.Pinner // the pinning manager
72 - Mounts Mounts `optional:"true"` // current mount state, if any.
73 - PrivateKey ic.PrivKey // the local node's private Key
74 - PNetFingerprint node.PNetFingerprint `optional:"true"` // fingerprint of private network
72 + Pinning pin.Pinner // the pinning manager
73 + Mounts Mounts `optional:"true"` // current mount state, if any.
74 + PrivateKey ic.PrivKey // the local node's private Key
75 + PNetFingerprint libp2p.PNetFingerprint `optional:"true"` // fingerprint of private network
76
77 // Services
78 Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances
core/mock/mock.go
+7 -7
@@ -2,21 +2,21 @@ package coremock
2
3 import (
4 "context"
5 + libp2p2 "github.com/ipfs/go-ipfs/core/node/libp2p"
6
6 - commands "github.com/ipfs/go-ipfs/commands"
7 - core "github.com/ipfs/go-ipfs/core"
8 - "github.com/ipfs/go-ipfs/core/node"
7 + "github.com/ipfs/go-ipfs/commands"
8 + "github.com/ipfs/go-ipfs/core"
9 "github.com/ipfs/go-ipfs/repo"
10
11 - datastore "github.com/ipfs/go-datastore"
11 + "github.com/ipfs/go-datastore"
12 syncds "github.com/ipfs/go-datastore/sync"
13 config "github.com/ipfs/go-ipfs-config"
14 - libp2p "github.com/libp2p/go-libp2p"
14 + "github.com/libp2p/go-libp2p"
15 host "github.com/libp2p/go-libp2p-host"
16 peer "github.com/libp2p/go-libp2p-peer"
17 pstore "github.com/libp2p/go-libp2p-peerstore"
18 mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
19 - testutil "github.com/libp2p/go-testutil"
19 + "github.com/libp2p/go-testutil"
20 )
21
22 // NewMockNode constructs an IpfsNode for use in tests.
@@ -30,7 +30,7 @@ func NewMockNode() (*core.IpfsNode, error) {
30 })
31 }
32
33 -func MockHostOption(mn mocknet.Mocknet) node.HostOption {
33 +func MockHostOption(mn mocknet.Mocknet) libp2p2.HostOption {
34 return func(ctx context.Context, id peer.ID, ps pstore.Peerstore, _ ...libp2p.Option) (host.Host, error) {
35 return mn.AddPeerWithPeerstore(id, ps)
36 }
core/node/builder.go
+13 -8
@@ -8,15 +8,20 @@ import (
8
9 "go.uber.org/fx"
10
11 + "github.com/ipfs/go-ipfs/core/node/helpers"
12 + "github.com/ipfs/go-ipfs/core/node/libp2p"
13 "github.com/ipfs/go-ipfs/repo"
14
15 ds "github.com/ipfs/go-datastore"
16 dsync "github.com/ipfs/go-datastore/sync"
17 cfg "github.com/ipfs/go-ipfs-config"
18 + logging "github.com/ipfs/go-log"
19 ci "github.com/libp2p/go-libp2p-crypto"
20 peer "github.com/libp2p/go-libp2p-peer"
21 )
22
23 +var log = logging.Logger("node")
24 +
25 type BuildCfg struct {
26 // If online is set, the node will have networking enabled
27 Online bool
@@ -35,8 +40,8 @@ type BuildCfg struct {
40 // If NilRepo is set, a Repo backed by a nil datastore will be constructed
41 NilRepo bool
42
38 - Routing RoutingOption
39 - Host HostOption
43 + Routing libp2p.RoutingOption
44 + Host libp2p.HostOption
45 Repo repo.Repo
46 }
47
@@ -68,11 +73,11 @@ func (cfg *BuildCfg) fillDefaults() error {
73 }
74
75 if cfg.Routing == nil {
71 - cfg.Routing = DHTOption
76 + cfg.Routing = libp2p.DHTOption
77 }
78
79 if cfg.Host == nil {
75 - cfg.Host = DefaultHostOption
80 + cfg.Host = libp2p.DefaultHostOption
81 }
82
83 return nil
@@ -94,15 +99,15 @@ func (cfg *BuildCfg) options(ctx context.Context) fx.Option {
99 return cfg.Repo
100 })
101
97 - metricsCtx := fx.Provide(func() MetricsCtx {
98 - return MetricsCtx(ctx)
102 + metricsCtx := fx.Provide(func() helpers.MetricsCtx {
103 + return helpers.MetricsCtx(ctx)
104 })
105
101 - hostOption := fx.Provide(func() HostOption {
106 + hostOption := fx.Provide(func() libp2p.HostOption {
107 return cfg.Host
108 })
109
105 - routingOption := fx.Provide(func() RoutingOption {
110 + routingOption := fx.Provide(func() libp2p.RoutingOption {
111 return cfg.Routing
112 })
113
core/node/core.go
+5 -5
@@ -4,6 +4,7 @@ import (
4 "context"
5 "fmt"
6
7 + "github.com/ipfs/go-ipfs/core/node/helpers"
8 "github.com/ipfs/go-ipfs/pin"
9 "github.com/ipfs/go-ipfs/repo"
10
@@ -54,9 +55,9 @@ func DagCtor(bs blockservice.BlockService) format.DAGService {
55 return merkledag.NewDAGService(bs)
56 }
57
57 -func OnlineExchangeCtor(mctx MetricsCtx, lc fx.Lifecycle, host host.Host, rt routing.IpfsRouting, bs blockstore.GCBlockstore) exchange.Interface {
58 +func OnlineExchangeCtor(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt routing.IpfsRouting, bs blockstore.GCBlockstore) exchange.Interface {
59 bitswapNetwork := network.NewFromIpfsHost(host, rt)
59 - exch := bitswap.New(lifecycleCtx(mctx, lc), bitswapNetwork, bs)
60 + exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, bs)
61 lc.Append(fx.Hook{
62 OnStop: func(ctx context.Context) error {
63 return exch.Close()
@@ -65,7 +66,7 @@ func OnlineExchangeCtor(mctx MetricsCtx, lc fx.Lifecycle, host host.Host, rt rou
66 return exch
67 }
68
68 -func Files(mctx MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, error) {
69 +func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, error) {
70 dsk := datastore.NewKey("/local/filesroot")
71 pf := func(ctx context.Context, c cid.Cid) error {
72 return repo.Datastore().Put(dsk, c.Bytes())
@@ -73,7 +74,7 @@ func Files(mctx MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGServi
74
75 var nd *merkledag.ProtoNode
76 val, err := repo.Datastore().Get(dsk)
76 - ctx := lifecycleCtx(mctx, lc)
77 + ctx := helpers.LifecycleCtx(mctx, lc)
78
79 switch {
80 case err == datastore.ErrNotFound || val == nil:
@@ -114,4 +115,3 @@ func Files(mctx MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGServi
115 return root, err
116 }
117
117 -type MetricsCtx context.Context
core/node/groups.go
+27 -26
@@ -3,6 +3,7 @@ package node
3 import (
4 "context"
5
6 + "github.com/ipfs/go-ipfs/core/node/libp2p"
7 "github.com/ipfs/go-ipfs/p2p"
8 "github.com/ipfs/go-ipfs/provider"
9
@@ -13,38 +14,38 @@ import (
14 )
15
16 var BaseLibP2P = fx.Options(
16 - fx.Provide(P2PAddrFilters),
17 - fx.Provide(P2PBandwidthCounter),
18 - fx.Provide(P2PPNet),
19 - fx.Provide(P2PAddrsFactory),
20 - fx.Provide(P2PConnectionManager),
21 - fx.Provide(P2PNatPortMap),
22 - fx.Provide(P2PRelay),
23 - fx.Provide(P2PAutoRealy),
24 - fx.Provide(P2PDefaultTransports),
25 - fx.Provide(P2PQUIC),
26 -
27 - fx.Provide(P2PHost),
28 -
29 - fx.Provide(NewDiscoveryHandler),
30 -
31 - fx.Invoke(AutoNATService),
32 - fx.Invoke(P2PPNetChecker),
33 - fx.Invoke(StartListening),
34 - fx.Invoke(SetupDiscovery),
17 + fx.Provide(libp2p.P2PAddrFilters),
18 + fx.Provide(libp2p.P2PBandwidthCounter),
19 + fx.Provide(libp2p.P2PPNet),
20 + fx.Provide(libp2p.P2PAddrsFactory),
21 + fx.Provide(libp2p.P2PConnectionManager),
22 + fx.Provide(libp2p.P2PNatPortMap),
23 + fx.Provide(libp2p.P2PRelay),
24 + fx.Provide(libp2p.P2PAutoRealy),
25 + fx.Provide(libp2p.P2PDefaultTransports),
26 + fx.Provide(libp2p.P2PQUIC),
27 +
28 + fx.Provide(libp2p.P2PHost),
29 +
30 + fx.Provide(libp2p.NewDiscoveryHandler),
31 +
32 + fx.Invoke(libp2p.AutoNATService),
33 + fx.Invoke(libp2p.P2PPNetChecker),
34 + fx.Invoke(libp2p.StartListening),
35 + fx.Invoke(libp2p.SetupDiscovery),
36 )
37
38 func LibP2P(cfg *BuildCfg) fx.Option {
39 opts := fx.Options(
40 BaseLibP2P,
41
41 - fx.Provide(P2PSecurity(!cfg.DisableEncryptedConnections)),
42 - maybeProvide(Pubsub, cfg.getOpt("pubsub") || cfg.getOpt("ipnsps")),
42 + fx.Provide(libp2p.P2PSecurity(!cfg.DisableEncryptedConnections)),
43 + maybeProvide(libp2p.Pubsub, cfg.getOpt("pubsub") || cfg.getOpt("ipnsps")),
44
44 - fx.Provide(P2PSmuxTransport(cfg.getOpt("mplex"))),
45 - fx.Provide(P2PRouting),
46 - fx.Provide(P2PBaseRouting),
47 - maybeProvide(P2PPubsubRouter, cfg.getOpt("ipnsps")),
45 + fx.Provide(libp2p.P2PSmuxTransport(cfg.getOpt("mplex"))),
46 + fx.Provide(libp2p.P2PRouting),
47 + fx.Provide(libp2p.P2PBaseRouting),
48 + maybeProvide(libp2p.P2PPubsubRouter, cfg.getOpt("ipnsps")),
49 )
50
51 return opts
@@ -62,7 +63,7 @@ func Storage(cfg *BuildCfg) fx.Option {
63 var Identity = fx.Options(
64 fx.Provide(PeerID),
65 fx.Provide(PrivateKey),
65 - fx.Provide(Peerstore),
66 + fx.Provide(libp2p.Peerstore),
67 )
68
69 var IPNS = fx.Options(
core/node/helpers.go
-15
@@ -10,21 +10,6 @@ import (
10 "go.uber.org/fx"
11 )
12
13 -// lifecycleCtx creates a context which will be cancelled when lifecycle stops
14 -//
15 -// This is a hack which we need because most of our services use contexts in a
16 -// wrong way
17 -func lifecycleCtx(mctx MetricsCtx, lc fx.Lifecycle) context.Context {
18 - ctx, cancel := context.WithCancel(mctx)
19 - lc.Append(fx.Hook{
20 - OnStop: func(_ context.Context) error {
21 - cancel()
22 - return nil
23 - },
24 - })
25 - return ctx
26 -}
27 -
13 type lcProcess struct {
14 fx.In
15
core/node/helpers/helpers.go new
+23
@@ -0,0 +1,23 @@
1 +package helpers
2 +
3 +import (
4 + "context"
5 + "go.uber.org/fx"
6 +)
7 +
8 +type MetricsCtx context.Context
9 +
10 +// LifecycleCtx creates a context which will be cancelled when lifecycle stops
11 +//
12 +// This is a hack which we need because most of our services use contexts in a
13 +// wrong way
14 +func LifecycleCtx(mctx MetricsCtx, lc fx.Lifecycle) context.Context {
15 + ctx, cancel := context.WithCancel(mctx)
16 + lc.Append(fx.Hook{
17 + OnStop: func(_ context.Context) error {
18 + cancel()
19 + return nil
20 + },
21 + })
22 + return ctx
23 +}
core/node/libp2p/discovery.go renamed
+6 -5
@@ -1,10 +1,11 @@
1 -package node
1 +package libp2p
2
3 import (
4 "context"
5 "time"
6
7 "github.com/ipfs/go-ipfs-config"
8 + "github.com/ipfs/go-ipfs/core/node/helpers"
9 "github.com/libp2p/go-libp2p-host"
10 "github.com/libp2p/go-libp2p-peerstore"
11 "github.com/libp2p/go-libp2p/p2p/discovery"
@@ -27,20 +28,20 @@ func (dh *discoveryHandler) HandlePeerFound(p peerstore.PeerInfo) {
28 }
29 }
30
30 -func NewDiscoveryHandler(mctx MetricsCtx, lc fx.Lifecycle, host host.Host) *discoveryHandler {
31 +func NewDiscoveryHandler(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) *discoveryHandler {
32 return &discoveryHandler{
32 - ctx: lifecycleCtx(mctx, lc),
33 + ctx: helpers.LifecycleCtx(mctx, lc),
34 host: host,
35 }
36 }
37
37 -func SetupDiscovery(mctx MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host, handler *discoveryHandler) error {
38 +func SetupDiscovery(mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host, handler *discoveryHandler) error {
39 if cfg.Discovery.MDNS.Enabled {
40 mdns := cfg.Discovery.MDNS
41 if mdns.Interval == 0 {
42 mdns.Interval = 5
43 }
43 - service, err := discovery.NewMdnsService(lifecycleCtx(mctx, lc), host, time.Duration(mdns.Interval)*time.Second, discovery.ServiceTag)
44 + service, err := discovery.NewMdnsService(helpers.LifecycleCtx(mctx, lc), host, time.Duration(mdns.Interval)*time.Second, discovery.ServiceTag)
45 if err != nil {
46 log.Error("mdns error: ", err)
47 return nil
core/node/libp2p/libp2p.go renamed
+12 -11
@@ -1,4 +1,4 @@
1 -package node
1 +package libp2p
2
3 import (
4 "bytes"
@@ -45,10 +45,11 @@ import (
45 mamask "github.com/whyrusleeping/multiaddr-filter"
46 "go.uber.org/fx"
47
48 + "github.com/ipfs/go-ipfs/core/node/helpers"
49 "github.com/ipfs/go-ipfs/repo"
50 )
51
51 -var log = logging.Logger("node")
52 +var log = logging.Logger("p2pnode")
53
54 type HostOption func(ctx context.Context, id peer.ID, ps peerstore.Peerstore, options ...libp2p.Option) (host.Host, error)
55 type RoutingOption func(context.Context, host.Host, datastore.Batching, record.Validator) (routing.IpfsRouting, error)
@@ -396,13 +397,13 @@ type P2PHostOut struct {
397 Routing BaseRouting
398 }
399
399 -func P2PHost(mctx MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHostOut, err error) {
400 +func P2PHost(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHostOut, err error) {
401 opts := []libp2p.Option{libp2p.NoListenAddrs}
402 for _, o := range params.Opts {
403 opts = append(opts, o...)
404 }
405
405 - ctx := lifecycleCtx(mctx, lc)
406 + ctx := helpers.LifecycleCtx(mctx, lc)
407
408 opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) {
409 r, err := params.RoutingOption(ctx, h, params.Repo.Datastore(), params.Validator)
@@ -501,9 +502,9 @@ type p2pPSRoutingIn struct {
502 PubSub *pubsub.PubSub `optional:"true"`
503 }
504
504 -func P2PPubsubRouter(mctx MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (p2pRouterOut, *namesys.PubsubValueStore) {
505 +func P2PPubsubRouter(mctx helpers.MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (p2pRouterOut, *namesys.PubsubValueStore) {
506 psRouter := namesys.NewPubsubValueStore(
506 - lifecycleCtx(mctx, lc),
507 + helpers.LifecycleCtx(mctx, lc),
508 in.Host,
509 in.BaseRouting,
510 in.PubSub,
@@ -523,7 +524,7 @@ func P2PPubsubRouter(mctx MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (p2pRo
524 }, psRouter
525 }
526
526 -func AutoNATService(mctx MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host) error {
527 +func AutoNATService(mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host) error {
528 if !cfg.Swarm.EnableAutoNATService {
529 return nil
530 }
@@ -532,11 +533,11 @@ func AutoNATService(mctx MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host h
533 opts = append(opts, libp2p.DefaultTransports, libp2p.Transport(libp2pquic.NewTransport))
534 }
535
535 - _, err := autonat.NewAutoNATService(lifecycleCtx(mctx, lc), host, opts...)
536 + _, err := autonat.NewAutoNATService(helpers.LifecycleCtx(mctx, lc), host, opts...)
537 return err
538 }
539
539 -func Pubsub(mctx MetricsCtx, lc fx.Lifecycle, host host.Host, cfg *config.Config) (service *pubsub.PubSub, err error) {
540 +func Pubsub(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, cfg *config.Config) (service *pubsub.PubSub, err error) {
541 var pubsubOptions []pubsub.Option
542 if cfg.Pubsub.DisableSigning {
543 pubsubOptions = append(pubsubOptions, pubsub.WithMessageSigning(false))
@@ -550,10 +551,10 @@ func Pubsub(mctx MetricsCtx, lc fx.Lifecycle, host host.Host, cfg *config.Config
551 case "":
552 fallthrough
553 case "floodsub":
553 - service, err = pubsub.NewFloodSub(lifecycleCtx(mctx, lc), host, pubsubOptions...)
554 + service, err = pubsub.NewFloodSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...)
555
556 case "gossipsub":
556 - service, err = pubsub.NewGossipSub(lifecycleCtx(mctx, lc), host, pubsubOptions...)
557 + service, err = pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...)
558
559 default:
560 err = fmt.Errorf("Unknown pubsub router %s", cfg.Pubsub.Router)
core/node/provider.go
+7 -6
@@ -10,6 +10,7 @@ import (
10 "github.com/libp2p/go-libp2p-routing"
11 "go.uber.org/fx"
12
13 + "github.com/ipfs/go-ipfs/core/node/helpers"
14 "github.com/ipfs/go-ipfs/exchange/reprovide"
15 "github.com/ipfs/go-ipfs/pin"
16 "github.com/ipfs/go-ipfs/provider"
@@ -18,12 +19,12 @@ import (
19
20 const kReprovideFrequency = time.Hour * 12
21
21 -func ProviderQueue(mctx MetricsCtx, lc fx.Lifecycle, repo repo.Repo) (*provider.Queue, error) {
22 - return provider.NewQueue(lifecycleCtx(mctx, lc), "provider-v1", repo.Datastore())
22 +func ProviderQueue(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo) (*provider.Queue, error) {
23 + return provider.NewQueue(helpers.LifecycleCtx(mctx, lc), "provider-v1", repo.Datastore())
24 }
25
25 -func ProviderCtor(mctx MetricsCtx, lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting) provider.Provider {
26 - p := provider.NewProvider(lifecycleCtx(mctx, lc), queue, rt)
26 +func ProviderCtor(mctx helpers.MetricsCtx, lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting) provider.Provider {
27 + p := provider.NewProvider(helpers.LifecycleCtx(mctx, lc), queue, rt)
28
29 lc.Append(fx.Hook{
30 OnStart: func(ctx context.Context) error {
@@ -38,7 +39,7 @@ func ProviderCtor(mctx MetricsCtx, lc fx.Lifecycle, queue *provider.Queue, rt ro
39 return p
40 }
41
41 -func ReproviderCtor(mctx MetricsCtx, lc fx.Lifecycle, cfg *config.Config, bs BaseBlocks, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*reprovide.Reprovider, error) {
42 +func ReproviderCtor(mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, bs BaseBlocks, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*reprovide.Reprovider, error) {
43 var keyProvider reprovide.KeyChanFunc
44
45 switch cfg.Reprovider.Strategy {
@@ -53,7 +54,7 @@ func ReproviderCtor(mctx MetricsCtx, lc fx.Lifecycle, cfg *config.Config, bs Bas
54 default:
55 return nil, fmt.Errorf("unknown reprovider strategy '%s'", cfg.Reprovider.Strategy)
56 }
56 - return reprovide.NewReprovider(lifecycleCtx(mctx, lc), rt, keyProvider), nil
57 + return reprovide.NewReprovider(helpers.LifecycleCtx(mctx, lc), rt, keyProvider), nil
58 }
59
60 func Reprovider(cfg *config.Config, reprovider *reprovide.Reprovider) error {
core/node/storage.go
+3 -2
@@ -12,6 +12,7 @@ import (
12 config "github.com/ipfs/go-ipfs-config"
13 "go.uber.org/fx"
14
15 + "github.com/ipfs/go-ipfs/core/node/helpers"
16 "github.com/ipfs/go-ipfs/filestore"
17 "github.com/ipfs/go-ipfs/repo"
18 "github.com/ipfs/go-ipfs/thirdparty/cidv0v1"
@@ -37,8 +38,8 @@ func DatastoreCtor(repo repo.Repo) datastore.Datastore {
38
39 type BaseBlocks blockstore.Blockstore
40
40 -func BaseBlockstoreCtor(permanent bool, nilRepo bool) func(mctx MetricsCtx, repo repo.Repo, cfg *config.Config, lc fx.Lifecycle) (bs BaseBlocks, err error) {
41 - return func(mctx MetricsCtx, repo repo.Repo, cfg *config.Config, lc fx.Lifecycle) (bs BaseBlocks, err error) {
41 +func BaseBlockstoreCtor(permanent bool, nilRepo bool) func(mctx helpers.MetricsCtx, repo repo.Repo, cfg *config.Config, lc fx.Lifecycle) (bs BaseBlocks, err error) {
42 + return func(mctx helpers.MetricsCtx, repo repo.Repo, cfg *config.Config, lc fx.Lifecycle) (bs BaseBlocks, err error) {
43 rds := &retrystore.Datastore{
44 Batching: repo.Datastore(),
45 Delay: time.Millisecond * 200,
test/integration/bitswap_wo_routing_test.go
+3 -4
@@ -6,11 +6,10 @@ import (
6 "testing"
7
8 "github.com/ipfs/go-block-format"
9 + "github.com/ipfs/go-cid"
10 "github.com/ipfs/go-ipfs/core"
11 "github.com/ipfs/go-ipfs/core/mock"
11 - "github.com/ipfs/go-ipfs/core/node"
12 -
13 - cid "github.com/ipfs/go-cid"
12 + "github.com/ipfs/go-ipfs/core/node/libp2p"
13 mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
14 )
15
@@ -27,7 +26,7 @@ func TestBitswapWithoutRouting(t *testing.T) {
26 n, err := core.NewNode(ctx, &core.BuildCfg{
27 Online: true,
28 Host: coremock.MockHostOption(mn),
30 - Routing: node.NilRouterOption, // no routing
29 + Routing: libp2p.NilRouterOption, // no routing
30 })
31 if err != nil {
32 t.Fatal(err)