Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 03f52a0

Browse files
committedDec 19, 2016
feat: pass CID directly into bitswap
1 parent 673ddf8 commit 03f52a0

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed
 

‎src/index.js

+12-17
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = class BlockService {
2121
}
2222

2323
isOnline () {
24-
return this._bitswap != null
24+
return this._bitswap !== null
2525
}
2626

2727
// Note: we have to pass the CID, so that bitswap can then use it for
@@ -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)
This repository has been archived.