send last 12 block times
This commit is contained in:
parent
00a531fb18
commit
f3fdabf0be
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user