@cryptotaxi247 / kubo / commits / 707874c3a

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

Brian Tiger Chow committed Jan 10, 2015 at 20:33 UTC 707874c3a595c87d5d46cecab3e6a1bb8ac0b997
2 files changed +4 -11
core/core.go
+4 -5
@@ -101,6 +101,10 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) {
101 // to be initialized at this point, and 2) which variables will be
102 // initialized after this point.
103
104 + node.Blocks, err = bserv.New(node.Blockstore, node.Exchange)
105 + if err != nil {
106 + return nil, debugerror.Wrap(err)
107 + }
108 node.DAG = merkledag.NewDAGService(node.Blocks)
109 node.Pinning, err = pin.LoadPinner(node.Datastore, node.DAG)
110 if err != nil {
@@ -167,11 +171,6 @@ func Standard(cfg *config.Config, online bool) ConfigOption {
171 n.Exchange = offline.Exchange(n.Blockstore)
172 }
173
170 - n.Blocks, err = bserv.New(n.Blockstore, n.Exchange)
171 - if err != nil {
172 - return nil, debugerror.Wrap(err)
173 - }
174 -
174 success = true
175 return n, nil
176 }
test/epictest/core.go
-6
@@ -6,7 +6,6 @@ import (
6 sync "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
7
8 blockstore "github.com/jbenet/go-ipfs/blocks/blockstore"
9 - blockservice "github.com/jbenet/go-ipfs/blockservice"
9 core "github.com/jbenet/go-ipfs/core"
10 bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
11 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
35 return nil, err
36 }
37 exch := bitswap.New(ctx, p, bsn, bstore, alwaysSendToPeer)
39 - blockservice, err := blockservice.New(bstore, exch)
40 - if err != nil {
41 - return nil, err
42 - }
38 return &core.IpfsNode{
39 Peerstore: h.Peerstore(),
40 Blockstore: bstore,
41 Exchange: exch,
42 Datastore: ds,
43 PeerHost: h,
49 - Blocks: blockservice,
44 Routing: dhtt,
45 Identity: p,
46 DHT: dhtt,