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.
feat: implement stats.vwbitswap and stats.repo
- Loading branch information
Showing
21 changed files
with
302 additions
and
42 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
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
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'stat', | ||
|
||
describe: 'Get stats for the currently used repo', | ||
|
||
builder: { | ||
human: { | ||
type: 'boolean', | ||
default: false | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.repo.stat({human: argv.human}, (err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
print(`repo status | ||
number of objects: ${stats.numObjects} | ||
repo size: ${stats.repoSize} | ||
repo path: ${stats.repoPath} | ||
version: ${stats.version} | ||
maximum storage: ${stats.storageMax}`) | ||
}) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'stats <command>', | ||
|
||
description: 'Query IPFS statistics.', | ||
|
||
builder (yargs) { | ||
return yargs.commandDir('stats') | ||
}, | ||
|
||
handler (argv) { | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'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 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'repo', | ||
|
||
describe: 'Get stats for the currently used repo', | ||
|
||
builder: { | ||
human: { | ||
type: 'boolean', | ||
default: false | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.stats.repo({human: argv.human}, (err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
print(`repo status | ||
number of objects: ${stats.numObjects} | ||
repo size: ${stats.repoSize} | ||
repo path: ${stats.repoPath} | ||
version: ${stats.version} | ||
maximum storage: ${stats.storageMax}`) | ||
}) | ||
} | ||
} |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = function stats (self) { | ||
return { | ||
bitswap: require('./bitswap')(self).stat, | ||
repo: require('./repo')(self).stat | ||
} | ||
} |
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
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
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
Oops, something went wrong.