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

Commit

Permalink
fix: use new bitswap stats (#1151)
Browse files Browse the repository at this point in the history
* fix: bitswap stats: use new bitswap stats, but keep the old interface (for now)

* fix: bitswap stat tests

* chore: using latest ipfs-bitswap version
  • Loading branch information
pgte authored and daviddias committed Dec 15, 2017
1 parent 34f28ef commit e223888
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions src/core/components/bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 6 additions & 0 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,14 @@ describe('bitswap', function () {

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

0 comments on commit e223888

Please sign in to comment.