1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 19:24:14 +08:00

misc: move initialization sqaush

This commit is contained in:
Brian Tiger Chow
2015-01-10 20:00:39 -08:00
parent efb75ee5ba
commit 401b8f413d

View File

@ -42,12 +42,6 @@ func makeCore(ctx context.Context, rf RepoFactory) (*Core, error) {
return nil, err return nil, err
} }
node.Blocks, err = blockservice.New(node.Blockstore, node.Exchange)
if err != nil {
return nil, err
}
node.DAG = merkledag.NewDAGService(node.Blocks)
// to make sure nothing is omitted, init each individual field and assign // to make sure nothing is omitted, init each individual field and assign
// all at once at the bottom. // all at once at the bottom.
return &Core{ return &Core{
@ -111,12 +105,19 @@ func MocknetTestRepo(p peer.ID, h host.Host, conf testutil.LatencyConfig) RepoFa
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,
DAG: merkledag.NewDAGService(blockservice),
Blocks: blockservice,
Routing: dhtt, Routing: dhtt,
Identity: p, Identity: p,
DHT: dhtt, DHT: dhtt,