Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 63eeece

Browse files
authored
Merge pull request #682 from ipfs/feat/update-bitswap
Use new bitswap
2 parents 154f17b + 9db86f5 commit 63eeece

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"coverage": "gulp coverage",
2323
"test": "gulp test",
2424
"test:unit:node": "gulp test:node",
25-
"test:unit:node:core": "TEST=core npm run test:node",
26-
"test:unit:node:http": "TEST=http npm run test:node",
27-
"test:unit:node:cli": "TEST=cli npm run test:node",
25+
"test:unit:node:core": "TEST=core npm run test:unit:node",
26+
"test:unit:node:http": "TEST=http npm run test:unit:node",
27+
"test:unit:node:cli": "TEST=cli npm run test:unit:node",
2828
"test:unit:browser": "gulp test:browser",
2929
"test:interop": "mocha -t 60000 test/interop",
3030
"test:interop:node": "mocha -t 60000 test/interop/node.js",
@@ -92,9 +92,9 @@
9292
"hapi-set-header": "^1.0.2",
9393
"idb-pull-blob-store": "^0.5.1",
9494
"ipfs-api": "^12.1.2",
95-
"ipfs-bitswap": "^0.8.3",
95+
"ipfs-bitswap": "^0.9.0",
9696
"ipfs-block": "^0.5.4",
97-
"ipfs-block-service": "^0.7.2",
97+
"ipfs-block-service": "^0.8.0",
9898
"ipfs-multipart": "^0.1.0",
9999
"ipfs-repo": "^0.11.2",
100100
"ipfs-unixfs": "^0.1.9",

src/cli/commands/bitswap/stat.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const utils = require('../../utils')
4+
const CID = require('cids')
45

56
module.exports = {
67
command: 'stat',
@@ -21,6 +22,11 @@ module.exports = {
2122
}
2223

2324
stats.Wantlist = stats.Wantlist || []
25+
stats.Wantlist = stats.Wantlist.map((entry) => {
26+
const buf = new Buffer(entry.cid.hash.data)
27+
const cid = new CID(entry.cid.version, entry.cid.codec, buf)
28+
return cid.toBaseEncodedString()
29+
})
2430
stats.Peers = stats.Peers || []
2531

2632
console.log(`bitswap status

src/cli/commands/bitswap/wantlist.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ module.exports = {
2626
if (err) {
2727
throw err
2828
}
29-
res.Keys.forEach((k) => console.log(k))
29+
res.Keys.forEach((cidStr) => {
30+
console.log(cidStr)
31+
})
3032
})
3133
})
3234
}

src/core/components/bitswap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR
44

55
function formatWantlist (list) {
6-
return Array.from(list).map((e) => e[0])
6+
return Array.from(list).map((e) => e[1])
77
}
88

99
module.exports = function bitswap (self) {

src/core/components/go-online.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = function goOnline (self) {
1414
}
1515

1616
self._bitswap = new Bitswap(
17-
{}, // TODO remove when new bitswap is merged
1817
self._libp2pNode,
1918
self._repo.blockstore,
2019
self._libp2pNode.peerBook

src/http-api/resources/bitswap.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports.wantlist = (request, reply) => {
1010
let list
1111
try {
1212
list = request.server.app.ipfs.bitswap.wantlist()
13+
list = list.map((entry) => entry.cid.toBaseEncodedString())
1314
} catch (err) {
1415
return reply(boom.badRequest(err))
1516
}

0 commit comments

Comments
 (0)