From f3fdabf0be117d0c0414975a5bf8221c4dcf381b Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 23 Feb 2015 16:47:18 +0200 Subject: [PATCH] send last 12 block times --- lib/node.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node.js b/lib/node.js index c7474bb..8cd766f 100644 --- a/lib/node.js +++ b/lib/node.js @@ -11,6 +11,7 @@ var Primus = require('primus'), Socket = Primus.createSocket({ transformer: 'websockets', pathname: '/api', + timeout: 20000, plugin: {emitter: Emitter, sparkLatency: Latency} }); @@ -53,6 +54,7 @@ function Node() blocktimeAvg: 0, difficulty: [], txDensity: [], + blockTimes: [], uptime: 0, errors: [] }; @@ -198,6 +200,7 @@ Node.prototype.getLatestBlocks = function() this.addBlockHistory(this.stats.block); + this.stats.blockTimes = this.calculateBlockTimes(); this.stats.blocktimeAvg = this.blockTimesAvg(); this.stats.difficulty = this.difficultyChart(); this.stats.txDensity = this.txDensityChart(); @@ -234,10 +237,9 @@ Node.prototype.calculateBlockTimes = function() Node.prototype.blockTimesAvg = function() { - var blockTimes = this.calculateBlockTimes(); - var sum = _.reduce(blockTimes, function(memo, time) { return memo + time;}, 0); + var sum = _.reduce(this.stats.blockTimes, function(memo, time) { return memo + time;}, 0); - return sum/blockTimes.length; + return sum/this.stats.blockTimes.length; } Node.prototype.difficultyChart = function()