Skip to content

Commit 87ae962

Browse files
committed
Add more networking info to list
1 parent 49bd7ae commit 87ae962

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

bin/list.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const request = require('request-promise-native')
2+
const pretty = require('prettier-bytes')
23
const chalk = require('chalk')
34

45
const { loadMetadata } = require('../lib/metadata')
@@ -19,13 +20,14 @@ exports.handler = async function (argv) {
1920
for (let key of Object.keys(rsp.body)) {
2021
const { mnt, networking } = rsp.body[key]
2122
console.log(`${chalk.green(key)} => ${chalk.green(mnt)}`)
22-
console.log(` Network Stats:`)
23-
console.log(` Metadata:`)
24-
console.log(` Uploaded: ${networking.metadata.totals.uploadedBytes / 1e6} MB`)
25-
console.log(` Downloaded: ${networking.metadata.totals.downloadedBytes / 1e6} MB`)
26-
console.log(` Content:`)
27-
console.log(` Uploaded: ${networking.content.totals.uploadedBytes / 1e6} MB`)
28-
console.log(` Downloaded: ${networking.content.totals.downloadedBytes / 1e6} MB`)
23+
console.log(chalk.yellow(` Metadata:`))
24+
console.log(` Connected Peers: ${networking.metadata.peers}`)
25+
console.log(` Uploaded: ${pretty(networking.metadata.totals.uploadedBytes)}`)
26+
console.log(` Downloaded: ${pretty(networking.metadata.totals.downloadedBytes)}`)
27+
console.log(chalk.yellow(` Content:`))
28+
console.log(` Connected Peers: ${networking.content.peers}`)
29+
console.log(` Uploaded: ${pretty(networking.content.totals.uploadedBytes)}`)
30+
console.log(` Downloaded: ${pretty(networking.content.totals.downloadedBytes)}`)
2931
}
3032
} else {
3133
console.log(chalk.orange('Cannot get the deamon\'s mount list.'))

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,14 @@ class Hypermount {
112112
const entry = result[record.key] = { mnt }
113113
const drive = this.drives.get(record.key)
114114
entry.networking = {
115-
metadata: drive.metadata.stats,
116-
content: drive.content && drive.content.stats
115+
metadata: {
116+
...drive.metadata.stats,
117+
peers: drive.metadata.peers.length
118+
},
119+
content: drive.content && {
120+
...drive.content.stats,
121+
peers: drive.content.peers.length
122+
}
117123
}
118124
})
119125
stream.on('end', () => {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"level": "^4.0.0",
4040
"mkdirp": "^0.5.1",
4141
"ora": "^3.4.0",
42+
"prettier-bytes": "^1.0.4",
4243
"random-access-memory": "^3.1.1",
4344
"request": "^2.88.0",
4445
"request-promise-native": "^1.0.7",

0 commit comments

Comments
 (0)