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