From e7546b67ce8927de7b5c218b499a4d5a89fc05e8 Mon Sep 17 00:00:00 2001 From: roks0n Date: Sun, 5 May 2019 22:02:18 +0200 Subject: [PATCH] order height stats --- app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 7140651..75e350b 100644 --- a/app.js +++ b/app.js @@ -16,6 +16,7 @@ const report = (crawler) => { } else { blockStats[item.height] = {} blockStats[item.height].count = 1 + blockStats[item.height].height = item.height blockStats[item.height].ids = {} blockStats[item.height].ids[item.id] = 1 } @@ -42,17 +43,17 @@ const report = (crawler) => { // height/block stats console.log(`Height and block stats:`) - for (const stat in blockStats) { - console.log(` ${blockStats[stat].count} nodes on height ${stat} with hashes:`) - for (const hash in blockStats[stat].ids) { - console.log(` - ${hash} (${blockStats[stat].ids[hash]} nodes)`) + for (const stat of orderBy(Object.values(blockStats), ['height'], ['desc'])) { + console.log(` ${stat.count} nodes on height ${stat.height} with hashes:`) + for (const hash in stat.ids) { + console.log(` - ${hash} (${stat.ids[hash]} nodes)`) } } // version stats console.log(``) console.log(`Version stats:`) - for (const stat of orderBy(Object.values(versionStats))) { + for (const stat of orderBy(Object.values(versionStats), ['version'], ['desc'])) { console.log(` - ${stat.count} nodes on version ${stat.version}`) }