From b5aff9f3e0bc98f00212217534fbed28f68ff069 Mon Sep 17 00:00:00 2001 From: Alexander Leitner Date: Mon, 17 Jul 2017 12:14:17 -0400 Subject: [PATCH] Display data received count on storjshare status --- bin/storjshare-status.js | 15 +++++++++++---- package.json | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/storjshare-status.js b/bin/storjshare-status.js index 14574de..3253d40 100755 --- a/bin/storjshare-status.js +++ b/bin/storjshare-status.js @@ -79,7 +79,7 @@ function prepareJson(shares) { json[i].uptime = prettyMs(share.meta.uptimeMs); json[i].restarts = share.meta.numRestarts || 0; json[i].peers = share.meta.farmerState.totalPeers || 0; - json[i].contracts = fixContractValue( + json[i].offers = fixContractValue( share.meta.farmerState.contractCount ); json[i].dataReceivedCount = fixContractValue( @@ -103,12 +103,12 @@ utils.connectToDaemon(port, function(rpc, sock) { } else { let table = new Table({ head: ['Share', 'Status', 'Uptime', 'Restarts', 'Peers', - 'Contracts', 'Delta', 'Port', 'Shared'], + 'Offers', 'Delta', 'Port', 'Shared'], style: { head: ['cyan', 'bold'], border: [] }, - colWidths: [45, 10, 10, 10, 10, 11, 9, 11, 10] + colWidths: [45, 9, 10, 10, 9, 15, 9, 10, 9] }); shares.forEach((share) => { let status = '?'; @@ -138,13 +138,20 @@ utils.connectToDaemon(port, function(rpc, sock) { let contracts = fixContractValue(share.meta.farmerState.contractCount); + let percentDataReceived = ( + share.meta.farmerState.dataReceivedCount !== 0 ? + Math.round( + fixContractValue(share.meta.farmerState.dataReceivedCount) / + fixContractValue(share.meta.farmerState.contractCount) * 100 + ) : 0); + table.push([ `${share.id}\n → ${share.config.storagePath}`, status, prettyMs(share.meta.uptimeMs), share.meta.numRestarts || 0, share.meta.farmerState.totalPeers || 0, - contracts, + contracts + '\n' + `${percentDataReceived}% received`, ntpStatus, port + '\n' + connectionType, share.meta.farmerState.spaceUsed + '\n' + diff --git a/package.json b/package.json index 7952021..cc7e66c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "storjshare-daemon", - "version": "3.4.2", + "version": "3.5.0", "description": "daemon + process manager for sharing space on the storj network", "main": "index.js", "bin": { @@ -76,7 +76,7 @@ "pretty-ms": "^2.1.0", "rc": "^1.1.6", "readable-stream": "^2.2.2", - "storj-lib": "^6.6.0", + "storj-lib": "^6.7.0", "storj-telemetry-reporter": "^5.0.0", "strip-json-comments": "^2.0.1", "tail": "^1.2.1"