Commit 34e8f3ee authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(core): init DAG and its dependents in shared constructor

fix: remove merkledag import

may need to squash this commit into the merkledag move commit
parent 7fa5d810
......@@ -96,6 +96,17 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) {
if err != nil {
return nil, err
}
// Need to make sure it's perfectly clear 1) which variables are expected
// to be initialized at this point, and 2) which variables will be
// initialized after this point.
node.DAG = merkledag.NewDAGService(node.Blocks)
node.Pinning, err = pin.LoadPinner(node.Datastore, node.DAG)
if err != nil {
node.Pinning = pin.NewPinner(node.Datastore, node.DAG)
}
node.Resolver = &path.Resolver{DAG: node.DAG}
return node, nil
}
......@@ -161,13 +172,6 @@ func Standard(cfg *config.Config, online bool) ConfigOption {
return nil, debugerror.Wrap(err)
}
n.DAG = merkledag.NewDAGService(n.Blocks)
n.Pinning, err = pin.LoadPinner(n.Datastore, n.DAG)
if err != nil {
n.Pinning = pin.NewPinner(n.Datastore, n.DAG)
}
n.Resolver = &path.Resolver{DAG: n.DAG}
success = true
return n, nil
}
......
......@@ -10,7 +10,6 @@ import (
core "github.com/jbenet/go-ipfs/core"
bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
merkledag "github.com/jbenet/go-ipfs/merkledag"
host "github.com/jbenet/go-ipfs/p2p/host"
peer "github.com/jbenet/go-ipfs/p2p/peer"
dht "github.com/jbenet/go-ipfs/routing/dht"
......@@ -47,7 +46,6 @@ func MocknetTestRepo(p peer.ID, h host.Host, conf testutil.LatencyConfig) core.C
Exchange: exch,
Datastore: ds,
PeerHost: h,
DAG: merkledag.NewDAGService(blockservice),
Blocks: blockservice,
Routing: dhtt,
Identity: p,
......
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