fixed blocktime
This commit is contained in:
parent
0a53f343c3
commit
959bc82154
@ -56,6 +56,20 @@ History.prototype.add = function(block, id, trusted, addingHistory)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No fork found => add a new one
|
// 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;
|
forkIndex = historyBlock.forks.push(block) - 1;
|
||||||
historyBlock.forks[forkIndex].fork = forkIndex;
|
historyBlock.forks[forkIndex].fork = forkIndex;
|
||||||
}
|
}
|
||||||
@ -97,6 +111,20 @@ History.prototype.add = function(block, id, trusted, addingHistory)
|
|||||||
block.received = historyBlock.propagTimes[propIndex].received;
|
block.received = historyBlock.propagTimes[propIndex].received;
|
||||||
block.propagation = historyBlock.propagTimes[propIndex].propagation;
|
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;
|
forkIndex = historyBlock.forks.push(block) - 1;
|
||||||
historyBlock.forks[forkIndex].fork = forkIndex;
|
historyBlock.forks[forkIndex].fork = forkIndex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user