From df47834021d03e43792aace2ea2b4c6914744618 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 28 Apr 2015 07:25:15 +0300 Subject: [PATCH] added getCharts in history --- models/history.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/models/history.js b/models/history.js index 94c28c6..ac8349c 100644 --- a/models/history.js +++ b/models/history.js @@ -225,6 +225,21 @@ History.prototype.getBlockTimes = function() return blockTimes; } +History.prototype.getDifficulty = function() +{ + var difficultyHistory = _(this._items) + .sortByOrder('height', false) + .slice(0, MAX_BINS) + .reverse() + .map(function(item) + { + return item.block.difficulty; + }) + .value(); + + return difficultyHistory; +} + History.prototype.getTransactionsCount = function() { var txCount = _(this._items) @@ -255,19 +270,26 @@ History.prototype.getGasSpending = function() return gasSpending; } -History.prototype.getDifficulty = function() +History.prototype.getCharts = function() { - var difficultyHistory = _(this._items) + var chartHistory = _(this._items) .sortByOrder('height', false) .slice(0, MAX_BINS) .reverse() .map(function(item) { - return item.block.difficulty; + var chart = { + blocktime: item.block.time, + difficulty: item.block.difficulty, + uncles: item.block.uncles.length, + transactions: item.block.transactions.length, + gasSpending: item.block.gasUsed + } + return chart; }) .value(); - return difficultyHistory; + return chartHistory; } History.prototype.history = function()