From 673ddf838e9cdd79ab11b19812caa5438b13d166 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 19 Dec 2016 06:43:28 +0000 Subject: [PATCH 1/2] chore: update deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a7cfa52..a55447c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ }, "homepage": "https://github.com/ipfs/js-ipfs-block-service#readme", "devDependencies": { - "aegir": "^9.2.2", + "aegir": "^9.3.0", "buffer-loader": "0.0.1", "chai": "^3.5.0", "fs-pull-blob-store": "^0.4.1", @@ -45,7 +45,7 @@ "ipfs-repo": "^0.11.2", "lodash": "^4.17.2", "ncp": "^2.0.0", - "pre-commit": "^1.2.1", + "pre-commit": "^1.2.2", "rimraf": "^2.5.4" }, "engines": { @@ -53,7 +53,7 @@ }, "dependencies": { "async": "^2.1.4", - "cids": "^0.3.4" + "cids": "^0.3.5" }, "contributors": [ "David Dias ", From f0c3e42e44135b963df5d3e94dcae6479bf2ced3 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 19 Dec 2016 09:14:20 +0000 Subject: [PATCH 2/2] feat: pass CID directly into bitswap --- package.json | 4 ++-- src/index.js | 27 +++++++++++---------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a55447c..29ec00b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "chai": "^3.5.0", "fs-pull-blob-store": "^0.4.1", "idb-pull-blob-store": "^0.5.1", - "ipfs-block": "^0.5.3", + "ipfs-block": "^0.5.4", "ipfs-repo": "^0.11.2", "lodash": "^4.17.2", "ncp": "^2.0.0", @@ -64,4 +64,4 @@ "npmcdn-to-unpkg-bot ", "wanderer " ] -} \ No newline at end of file +} diff --git a/src/index.js b/src/index.js index c7df693..3ed7366 100644 --- a/src/index.js +++ b/src/index.js @@ -44,24 +44,19 @@ module.exports = class BlockService { } putStream () { - let ps if (this.isOnline()) { - // NOTE: This will have to change in order for bitswap - // to understand CID - ps = this._bitswap.putStream() + return this._bitswap.putStream() } else { - ps = this._repo.blockstore.putStream() + return pull( + pull.map((blockAndCID) => { + return { + data: blockAndCID.block.data, + key: blockAndCID.cid.multihash + } + }), + this._repo.blockstore.putStream() + ) } - - return pull( - pull.map((blockAndCID) => { - return { - data: blockAndCID.block.data, - key: blockAndCID.cid.multihash - } - }), - ps - ) } get (cid, callback) { @@ -78,7 +73,7 @@ module.exports = class BlockService { getStream (cid) { if (this.isOnline()) { - return this._bitswap.getStream(cid.multihash) + return this._bitswap.getStream(cid) } return this._repo.blockstore.getStream(cid.multihash)