Merge pull request #197 from cubedro/develop

fixed blocktime
This commit is contained in:
Marian OANCΞA 2015-06-17 05:18:15 +03:00
commit a4160eb74d

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;
}