This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 1 file changed +6
-35
lines changed
1 file changed +6
-35
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const CID = require ( 'cids' )
4
- const print = require ( '../../utils' ) . print
5
-
6
- module . exports = {
7
- command : 'bitswap' ,
8
-
9
- describe : 'Show some diagnostic information on the bitswap agent.' ,
10
-
11
- builder : { } ,
12
-
13
- handler ( argv ) {
14
- argv . ipfs . stats . bitswap ( ( err , stats ) => {
15
- if ( err ) {
16
- throw err
17
- }
18
-
19
- stats . wantlist = stats . wantlist || [ ]
20
- stats . wantlist = stats . wantlist . map ( ( entry ) => {
21
- const buf = Buffer . from ( entry . cid . hash . data )
22
- const cid = new CID ( entry . cid . version , entry . cid . codec , buf )
23
- return cid . toBaseEncodedString ( )
24
- } )
25
- stats . peers = stats . peers || [ ]
26
-
27
- print ( `bitswap status
28
- blocks received: ${ stats . blocksReceived }
29
- dup blocks received: ${ stats . dupBlksReceived }
30
- dup data received: ${ stats . dupDataReceived } B
31
- wantlist [${ stats . wantlist . length } keys]
32
- ${ stats . wantlist . join ( '\n ' ) }
33
- partners [${ stats . peers . length } ]
34
- ${ stats . peers . join ( '\n ' ) } ` )
35
- } )
36
- }
37
- }
3
+ // This is an alias for `bitswap stat`.
4
+ const bitswapStats = require ( '../bitswap/stat.js' )
5
+ // The command needs to be renamed, else it would be `stats stat` instead of
6
+ // `stats bitswap`
7
+ bitswapStats . command = 'bitswap'
8
+ module . exports = bitswapStats
You can’t perform that action at this time.
0 commit comments