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

Fix: use new bitswap stats #1151

Merged
merged 3 commits into from
Dec 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@
"hapi-set-header": "^1.0.2",
"hoek": "^5.0.2",
"ipfs-api": "^17.2.4",
"ipfs-bitswap": "~0.17.4",
"ipfs-bitswap": "~0.18.0",
"ipfs-block": "~0.6.1",
"ipfs-block-service": "~0.13.0",
"ipfs-multipart": "~0.1.0",
9 changes: 4 additions & 5 deletions src/core/components/bitswap.js
Original file line number Diff line number Diff line change
@@ -21,11 +21,10 @@ module.exports = function bitswap (self) {
throw new Error(OFFLINE_ERROR)
}

const stats = self._bitswap.stat()
stats.wantlist = formatWantlist(stats.wantlist)
stats.peers = stats.peers.map((id) => id.toB58String())

return stats
return Object.assign({}, self._bitswap.stat().snapshot, {
wantlist: formatWantlist(self._bitswap.getWantlist()),
peers: self._bitswap.peers().map((id) => id.toB58String())
})
},
unwant: (key) => {
if (!self.isOnline()) {
6 changes: 6 additions & 0 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
@@ -261,8 +261,14 @@ describe('bitswap', function () {

expect(stats).to.have.keys([
'blocksReceived',
'blocksSent',
'dataReceived',
'dataSent',
'wantListLength',
'wantlist',
'peerCount',
'peers',
'providesBufferLength',
'dupDataReceived',
'dupBlksReceived'
])