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

Commit f64441c

Browse files
authored
Merge pull request #51 from ipfs/feat/use-new-bitswap
feat/use new bitswap
2 parents 0fe3ae4 + f0c3e42 commit f64441c

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@
3636
},
3737
"homepage": "https://github.com/ipfs/js-ipfs-block-service#readme",
3838
"devDependencies": {
39-
"aegir": "^9.2.2",
39+
"aegir": "^9.3.0",
4040
"buffer-loader": "0.0.1",
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",
48-
"pre-commit": "^1.2.1",
48+
"pre-commit": "^1.2.2",
4949
"rimraf": "^2.5.4"
5050
},
5151
"engines": {
5252
"node": ">=4.0.0"
5353
},
5454
"dependencies": {
5555
"async": "^2.1.4",
56-
"cids": "^0.3.4"
56+
"cids": "^0.3.5"
5757
},
5858
"contributors": [
5959
"David Dias <daviddias.p@gmail.com>",
@@ -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)