diff --git a/lib/history.js b/lib/history.js index b238271..a60123e 100644 --- a/lib/history.js +++ b/lib/history.js @@ -276,14 +276,14 @@ History.prototype.prevMaxBlock = function(number) History.prototype.bestBlock = function() { - return _.max(this._items, 'height'); + return _.maxBy(this._items, 'height'); } History.prototype.bestBlockNumber = function() { var best = this.bestBlock(); - if( !_.isUndefined(best.height) ) + if( !_.isUndefined(best) && !_.isUndefined(best.height) ) return best.height; return 0; @@ -291,14 +291,14 @@ History.prototype.bestBlockNumber = function() History.prototype.worstBlock = function() { - return _.min(this._items, 'height'); + return _.minBy(this._items, 'height'); } History.prototype.worstBlockNumber = function(trusted) { var worst = this.worstBlock(); - if( !_.isUndefined(worst.height) ) + if( !_.isUndefined(worst) && !_.isUndefined(worst.height) ) return worst.height; return 0; @@ -335,8 +335,7 @@ History.prototype.getNodePropagation = function(id) } } }) - .reverse() - .value(); + .reverse(); return propagation; }