Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit f0c3e42

Browse files
committed
feat: pass CID directly into bitswap
1 parent 673ddf8 commit f0c3e42

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"chai": "^3.5.0",
4242
"fs-pull-blob-store": "^0.4.1",
4343
"idb-pull-blob-store": "^0.5.1",
44-
"ipfs-block": "^0.5.3",
44+
"ipfs-block": "^0.5.4",
4545
"ipfs-repo": "^0.11.2",
4646
"lodash": "^4.17.2",
4747
"ncp": "^2.0.0",
@@ -64,4 +64,4 @@
6464
"npmcdn-to-unpkg-bot <npmcdn-to-unpkg-bot@users.noreply.github.com>",
6565
"wanderer <mjbecze@gmail.com>"
6666
]
67-
}
67+
}

src/index.js

+11-16
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,19 @@ module.exports = class BlockService {
4444
}
4545

4646
putStream () {
47-
let ps
4847
if (this.isOnline()) {
49-
// NOTE: This will have to change in order for bitswap
50-
// to understand CID
51-
ps = this._bitswap.putStream()
48+
return this._bitswap.putStream()
5249
} else {
53-
ps = this._repo.blockstore.putStream()
50+
return pull(
51+
pull.map((blockAndCID) => {
52+
return {
53+
data: blockAndCID.block.data,
54+
key: blockAndCID.cid.multihash
55+
}
56+
}),
57+
this._repo.blockstore.putStream()
58+
)
5459
}
55-
56-
return pull(
57-
pull.map((blockAndCID) => {
58-
return {
59-
data: blockAndCID.block.data,
60-
key: blockAndCID.cid.multihash
61-
}
62-
}),
63-
ps
64-
)
6560
}
6661

6762
get (cid, callback) {
@@ -78,7 +73,7 @@ module.exports = class BlockService {
7873

7974
getStream (cid) {
8075
if (this.isOnline()) {
81-
return this._bitswap.getStream(cid.multihash)
76+
return this._bitswap.getStream(cid)
8277
}
8378

8479
return this._repo.blockstore.getStream(cid.multihash)

0 commit comments

Comments
 (0)