From 208b9bc94e794829c344f86bb38253b2d429be08 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 2 Dec 2024 23:37:02 +1100 Subject: [PATCH] peers --- scripts/bootstrap.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/bootstrap.js b/scripts/bootstrap.js index 86ce99311..155f63940 100755 --- a/scripts/bootstrap.js +++ b/scripts/bootstrap.js @@ -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 @@ -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 () => {