Commit 707874c3 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(core): init node.Blocks in shared NewIPFSNode constructor

parent 34e8f3ee
......@@ -101,6 +101,10 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) {
// to be initialized at this point, and 2) which variables will be
// initialized after this point.
node.Blocks, err = bserv.New(node.Blockstore, node.Exchange)
if err != nil {
return nil, debugerror.Wrap(err)
}
node.DAG = merkledag.NewDAGService(node.Blocks)
node.Pinning, err = pin.LoadPinner(node.Datastore, node.DAG)
if err != nil {
......@@ -167,11 +171,6 @@ func Standard(cfg *config.Config, online bool) ConfigOption {
n.Exchange = offline.Exchange(n.Blockstore)
}
n.Blocks, err = bserv.New(n.Blockstore, n.Exchange)
if err != nil {
return nil, debugerror.Wrap(err)
}
success = true
return n, nil
}
......
......@@ -6,7 +6,6 @@ import (
sync "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
blockstore "github.com/jbenet/go-ipfs/blocks/blockstore"
blockservice "github.com/jbenet/go-ipfs/blockservice"
core "github.com/jbenet/go-ipfs/core"
bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
......@@ -36,17 +35,12 @@ func MocknetTestRepo(p peer.ID, h host.Host, conf testutil.LatencyConfig) core.C
return nil, err
}
exch := bitswap.New(ctx, p, bsn, bstore, alwaysSendToPeer)
blockservice, err := blockservice.New(bstore, exch)
if err != nil {
return nil, err
}
return &core.IpfsNode{
Peerstore: h.Peerstore(),
Blockstore: bstore,
Exchange: exch,
Datastore: ds,
PeerHost: h,
Blocks: blockservice,
Routing: dhtt,
Identity: p,
DHT: dhtt,
......
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