Merge pull request #278 from cubedro/develop
Changed avg blocktime to be calculated from the entire history
This commit is contained in:
commit
8134928d5e
@ -429,13 +429,32 @@ History.prototype.getBlockTimes = function()
|
|||||||
.reverse()
|
.reverse()
|
||||||
.map(function (item)
|
.map(function (item)
|
||||||
{
|
{
|
||||||
return item.block.time;
|
return item.block.time / 1000;
|
||||||
})
|
})
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
return blockTimes;
|
return blockTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
History.prototype.getAvgBlocktime = function()
|
||||||
|
{
|
||||||
|
var blockTimes = _( this._items )
|
||||||
|
.sortByOrder( 'height', false )
|
||||||
|
// .filter(function (item)
|
||||||
|
// {
|
||||||
|
// return item.block.trusted;
|
||||||
|
// })
|
||||||
|
// .slice(0, MAX_BINS)
|
||||||
|
.reverse()
|
||||||
|
.map(function (item)
|
||||||
|
{
|
||||||
|
return item.block.time / 1000;
|
||||||
|
})
|
||||||
|
.value();
|
||||||
|
|
||||||
|
return _.sum(blockTimes) / (blockTimes.length === 0 ? 1 : blockTimes.length);
|
||||||
|
}
|
||||||
|
|
||||||
History.prototype.getGasLimit = function()
|
History.prototype.getGasLimit = function()
|
||||||
{
|
{
|
||||||
var gasLimitHistory = _( this._items )
|
var gasLimitHistory = _( this._items )
|
||||||
@ -598,7 +617,8 @@ History.prototype.getCharts = function()
|
|||||||
this._callback(null, {
|
this._callback(null, {
|
||||||
height : _.pluck( chartHistory, 'height' ),
|
height : _.pluck( chartHistory, 'height' ),
|
||||||
blocktime : _.pluck( chartHistory, 'blocktime' ),
|
blocktime : _.pluck( chartHistory, 'blocktime' ),
|
||||||
avgBlocktime : _.sum(_.pluck( chartHistory, 'blocktime' )) / (chartHistory.length === 0 ? 1 : chartHistory.length),
|
// avgBlocktime : _.sum(_.pluck( chartHistory, 'blocktime' )) / (chartHistory.length === 0 ? 1 : chartHistory.length),
|
||||||
|
avgBlocktime : this.getAvgBlocktime(),
|
||||||
difficulty : _.pluck( chartHistory, 'difficulty' ),
|
difficulty : _.pluck( chartHistory, 'difficulty' ),
|
||||||
uncles : _.pluck( chartHistory, 'uncles' ),
|
uncles : _.pluck( chartHistory, 'uncles' ),
|
||||||
transactions : _.pluck( chartHistory, 'transactions' ),
|
transactions : _.pluck( chartHistory, 'transactions' ),
|
||||||
|
Loading…
Reference in New Issue
Block a user