This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `stats bitswap` command is an alias of `bitswap stat`. That should also be reflected in the code.
- Loading branch information
Showing
1 changed file
with
6 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,8 @@ | ||
'use strict' | ||
|
||
const CID = require('cids') | ||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'bitswap', | ||
|
||
describe: 'Show some diagnostic information on the bitswap agent.', | ||
|
||
builder: {}, | ||
|
||
handler (argv) { | ||
argv.ipfs.stats.bitswap((err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
stats.wantlist = stats.wantlist || [] | ||
stats.wantlist = stats.wantlist.map((entry) => { | ||
const buf = Buffer.from(entry.cid.hash.data) | ||
const cid = new CID(entry.cid.version, entry.cid.codec, buf) | ||
return cid.toBaseEncodedString() | ||
}) | ||
stats.peers = stats.peers || [] | ||
|
||
print(`bitswap status | ||
blocks received: ${stats.blocksReceived} | ||
dup blocks received: ${stats.dupBlksReceived} | ||
dup data received: ${stats.dupDataReceived}B | ||
wantlist [${stats.wantlist.length} keys] | ||
${stats.wantlist.join('\n ')} | ||
partners [${stats.peers.length}] | ||
${stats.peers.join('\n ')}`) | ||
}) | ||
} | ||
} | ||
// This is an alias for `bitswap stat`. | ||
const bitswapStats = require('../bitswap/stat.js') | ||
// The command needs to be renamed, else it would be `stats stat` instead of | ||
// `stats bitswap` | ||
bitswapStats.command = 'bitswap' | ||
module.exports = bitswapStats |