fixed blocktime

This commit is contained in:
cubedro 2015-06-17 05:17:59 +03:00
parent 0a53f343c3
commit 959bc82154

View File

@ -56,6 +56,20 @@ History.prototype.add = function(block, id, trusted, addingHistory)
else
{
// No fork found => add a new one
var prevBlock = this.prevMaxBlock(block.number);
if( prevBlock )
{
block.time = Math.max(block.arrived - prevBlock.block.arrived, 0);
if(block.number < this.bestBlock().height)
block.time = Math.max((block.timestamp - prevBlock.block.timestamp) * 1000, 0);
}
else
{
block.time = 0;
}
forkIndex = historyBlock.forks.push(block) - 1;
historyBlock.forks[forkIndex].fork = forkIndex;
}
@ -97,6 +111,20 @@ History.prototype.add = function(block, id, trusted, addingHistory)
block.received = historyBlock.propagTimes[propIndex].received;
block.propagation = historyBlock.propagTimes[propIndex].propagation;
var prevBlock = this.prevMaxBlock(block.number);
if( prevBlock )
{
block.time = Math.max(block.arrived - prevBlock.block.arrived, 0);
if(block.number < this.bestBlock().height)
block.time = Math.max((block.timestamp - prevBlock.block.timestamp) * 1000, 0);
}
else
{
block.time = 0;
}
forkIndex = historyBlock.forks.push(block) - 1;
historyBlock.forks[forkIndex].fork = forkIndex;
}