fixed blocktime and blocktimeAvg
This commit is contained in:
parent
5d0d5d1576
commit
e3210fc00b
@ -24,8 +24,7 @@ if(process.env.NODE_ENV === 'production')
|
||||
|
||||
var socket = new Socket(process.env.WS_SERVER || 'ws://localhost:3000');
|
||||
|
||||
var MAX_BLOCKS_HISTORY = 12,
|
||||
LOWEST_TIMESTAMP = 0;
|
||||
var MAX_BLOCKS_HISTORY = 12;
|
||||
|
||||
function Node()
|
||||
{
|
||||
@ -206,11 +205,10 @@ Node.prototype.getLatestBlocks = function()
|
||||
|
||||
Node.prototype.addBlockHistory = function(block)
|
||||
{
|
||||
if(this.blocks.length === 0 || block.number != this.blocks[0].number)
|
||||
if(this.blocks.length === 0 || block.number !== this.blocks[0].number)
|
||||
{
|
||||
if(this.blocks.length === MAX_BLOCKS_HISTORY)
|
||||
{
|
||||
LOWEST_TIMESTAMP = this.blocks[MAX_BLOCKS_HISTORY - 1].timestamp;
|
||||
this.blocks.pop();
|
||||
}
|
||||
|
||||
@ -224,7 +222,7 @@ Node.prototype.calculateBlockTimes = function()
|
||||
|
||||
var blockTimes = _.map(this.blocks, function(block, key, list)
|
||||
{
|
||||
var diff = block.timestamp - (key < list.length - 1 ? list[key + 1].timestamp : LOWEST_TIMESTAMP);
|
||||
var diff = (key > 0 ? list[key - 1].timestamp : Math.floor(Date.now()/1000)) - block.timestamp;
|
||||
|
||||
self.blocks[key].blocktime = diff;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user