Skip to content

Commit

Permalink
peers
Browse files Browse the repository at this point in the history
  • Loading branch information
maidh91 committed Dec 2, 2024
1 parent 1566c44 commit 208b9bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ async function download (key, all = false) {
async function monitorDrive (drive) {
const downloadSpeedometer = speedometer()
const uploadSpeedometer = speedometer()
let peers = 0
let downloadedBytes = 0
let downloadSpeed = 0
let uploadPeers = 0
let uploadedBytes = 0
let uploadSpeed = 0

Expand All @@ -158,11 +160,17 @@ async function monitorDrive (drive) {
uploadedBytes += bytes
uploadSpeed = uploadSpeedometer(bytes)
})
blobs.core.on('peer-add', () => {
peers = blobs.core.peers.length
})
blobs.core.on('peer-remove', () => {
peers = blobs.core.peers.length
})

const interval = setInterval(() => {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(`[⬇ ${byteSize(downloadedBytes)} - ${byteSize(downloadSpeed)}/s] [⬆ ${byteSize(uploadedBytes)} - ${byteSize(uploadSpeed)}/s]`);
process.stdout.write(`[⬇ ${byteSize(downloadedBytes)} - ${byteSize(downloadSpeed)}/s - ${peers} peers] [⬆ ${byteSize(uploadedBytes)} - ${byteSize(uploadSpeed)}/s - ${peers} peers]`);
}, 500)

return () => {
Expand Down

0 comments on commit 208b9bc

Please sign in to comment.