|
|
|
@ -228,7 +228,7 @@ History.prototype._save = function(block) |
|
|
|
|
{ |
|
|
|
|
this._items.unshift(block); |
|
|
|
|
|
|
|
|
|
this._items = _.sortByOrder( this._items, 'height', false ); |
|
|
|
|
this._items = _.sortBy( this._items, 'height', false ); |
|
|
|
|
|
|
|
|
|
if(this._items.length > MAX_HISTORY) |
|
|
|
|
{ |
|
|
|
@ -314,7 +314,7 @@ History.prototype.getNodePropagation = function(id) |
|
|
|
|
_.fill(propagation, -1); |
|
|
|
|
|
|
|
|
|
var sorted = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
.slice( 0, MAX_PEER_PROPAGATION ) |
|
|
|
|
.forEach(function (item, key) |
|
|
|
|
{ |
|
|
|
@ -392,7 +392,7 @@ History.prototype.getBlockPropagation = function() |
|
|
|
|
History.prototype.getUncleCount = function() |
|
|
|
|
{ |
|
|
|
|
var uncles = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -420,7 +420,7 @@ History.prototype.getUncleCount = function() |
|
|
|
|
History.prototype.getBlockTimes = function() |
|
|
|
|
{ |
|
|
|
|
var blockTimes = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -439,7 +439,7 @@ History.prototype.getBlockTimes = function() |
|
|
|
|
History.prototype.getAvgBlocktime = function() |
|
|
|
|
{ |
|
|
|
|
var blockTimes = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -458,7 +458,7 @@ History.prototype.getAvgBlocktime = function() |
|
|
|
|
History.prototype.getGasLimit = function() |
|
|
|
|
{ |
|
|
|
|
var gasLimitHistory = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -477,7 +477,7 @@ History.prototype.getGasLimit = function() |
|
|
|
|
History.prototype.getDifficulty = function() |
|
|
|
|
{ |
|
|
|
|
var difficultyHistory = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
.filter(function (item) |
|
|
|
|
{ |
|
|
|
|
return item.block.trusted; |
|
|
|
@ -496,7 +496,7 @@ History.prototype.getDifficulty = function() |
|
|
|
|
History.prototype.getTransactionsCount = function() |
|
|
|
|
{ |
|
|
|
|
var txCount = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
.filter(function (item) |
|
|
|
|
{ |
|
|
|
|
return item.block.trusted; |
|
|
|
@ -515,7 +515,7 @@ History.prototype.getTransactionsCount = function() |
|
|
|
|
History.prototype.getGasSpending = function() |
|
|
|
|
{ |
|
|
|
|
var gasSpending = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
.filter(function (item) |
|
|
|
|
{ |
|
|
|
|
return item.block.trusted; |
|
|
|
@ -537,7 +537,7 @@ History.prototype.getAvgHashrate = function() |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
var blocktimeHistory = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -557,7 +557,7 @@ History.prototype.getAvgHashrate = function() |
|
|
|
|
History.prototype.getMinersCount = function() |
|
|
|
|
{ |
|
|
|
|
var miners = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -577,7 +577,7 @@ History.prototype.getMinersCount = function() |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return _(minerCount) |
|
|
|
|
.sortByOrder( 'blocks', false ) |
|
|
|
|
.sortBy( 'blocks', false ) |
|
|
|
|
.slice(0, 2) |
|
|
|
|
.value(); |
|
|
|
|
} |
|
|
|
@ -592,7 +592,7 @@ History.prototype.getCharts = function() |
|
|
|
|
if(this._callback !== null) |
|
|
|
|
{ |
|
|
|
|
var chartHistory = _( this._items ) |
|
|
|
|
.sortByOrder( 'height', false ) |
|
|
|
|
.sortBy( 'height', false ) |
|
|
|
|
// .filter(function (item)
|
|
|
|
|
// {
|
|
|
|
|
// return item.block.trusted;
|
|
|
|
@ -615,15 +615,15 @@ History.prototype.getCharts = function() |
|
|
|
|
.value(); |
|
|
|
|
|
|
|
|
|
this._callback(null, { |
|
|
|
|
height : _.pluck( chartHistory, 'height' ), |
|
|
|
|
blocktime : _.pluck( chartHistory, 'blocktime' ), |
|
|
|
|
// avgBlocktime : _.sum(_.pluck( chartHistory, 'blocktime' )) / (chartHistory.length === 0 ? 1 : chartHistory.length),
|
|
|
|
|
height : _.map( chartHistory, 'height' ), |
|
|
|
|
blocktime : _.map( chartHistory, 'blocktime' ), |
|
|
|
|
// avgBlocktime : _.sum(_.map( chartHistory, 'blocktime' )) / (chartHistory.length === 0 ? 1 : chartHistory.length),
|
|
|
|
|
avgBlocktime : this.getAvgBlocktime(), |
|
|
|
|
difficulty : _.pluck( chartHistory, 'difficulty' ), |
|
|
|
|
uncles : _.pluck( chartHistory, 'uncles' ), |
|
|
|
|
transactions : _.pluck( chartHistory, 'transactions' ), |
|
|
|
|
gasSpending : _.pluck( chartHistory, 'gasSpending' ), |
|
|
|
|
gasLimit : _.pluck( chartHistory, 'gasLimit' ), |
|
|
|
|
difficulty : _.map( chartHistory, 'difficulty' ), |
|
|
|
|
uncles : _.map( chartHistory, 'uncles' ), |
|
|
|
|
transactions : _.map( chartHistory, 'transactions' ), |
|
|
|
|
gasSpending : _.map( chartHistory, 'gasSpending' ), |
|
|
|
|
gasLimit : _.map( chartHistory, 'gasLimit' ), |
|
|
|
|
miners : this.getMinersCount(), |
|
|
|
|
propagation : this.getBlockPropagation(), |
|
|
|
|
uncleCount : this.getUncleCount(), |
|
|
|
@ -643,7 +643,7 @@ History.prototype.getHistoryRequestRange = function() |
|
|
|
|
if( this._items.length < 2 ) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
var blocks = _.pluck( this._items, 'height' ); |
|
|
|
|
var blocks = _.map( this._items, 'height' ); |
|
|
|
|
var best = _.max( blocks ); |
|
|
|
|
var range = _.range( _.max([ 0, best - MAX_HISTORY ]), best + 1); |
|
|
|
|
|
|
|
|
|