Merge pull request #163 from cubedro/develop
Added null validation for block fetch
This commit is contained in:
commit
5b95fa937d
13
lib/node.js
13
lib/node.js
@ -105,7 +105,6 @@ function Node ()
|
|||||||
this._socket = false;
|
this._socket = false;
|
||||||
|
|
||||||
this._latestQueue = null;
|
this._latestQueue = null;
|
||||||
this._chainDebouncer = 0;
|
|
||||||
this.pendingFilter = false;
|
this.pendingFilter = false;
|
||||||
this.chainFilter = false;
|
this.chainFilter = false;
|
||||||
this.updateInterval = false;
|
this.updateInterval = false;
|
||||||
@ -114,7 +113,9 @@ function Node ()
|
|||||||
|
|
||||||
this._lastChainLog = 0;
|
this._lastChainLog = 0;
|
||||||
this._lastPendingLog = 0;
|
this._lastPendingLog = 0;
|
||||||
|
this._chainDebouncer = 0;
|
||||||
this._connection_attempts = 0
|
this._connection_attempts = 0
|
||||||
|
this._timeOffset = null;
|
||||||
|
|
||||||
this.startWeb3Connection();
|
this.startWeb3Connection();
|
||||||
|
|
||||||
@ -216,7 +217,8 @@ Node.prototype.setupSockets = function()
|
|||||||
})
|
})
|
||||||
.on('node-pong', function(data)
|
.on('node-pong', function(data)
|
||||||
{
|
{
|
||||||
var latency = Math.ceil( (_.now() - self._latency) / 2 );
|
var now = _.now();
|
||||||
|
var latency = Math.ceil( (now - data.clientTime) / 2 );
|
||||||
|
|
||||||
socket.emit('latency', {
|
socket.emit('latency', {
|
||||||
id: self.id,
|
id: self.id,
|
||||||
@ -339,7 +341,7 @@ Node.prototype.setUptime = function()
|
|||||||
|
|
||||||
Node.prototype.formatBlock = function (block)
|
Node.prototype.formatBlock = function (block)
|
||||||
{
|
{
|
||||||
if( !_.isUndefined(block) && !_.isUndefined(block.number) && block.number >= 0 && !_.isUndefined(block.difficulty) && !_.isUndefined(block.totalDifficulty) )
|
if( !_.isNull(block) && !_.isUndefined(block) && !_.isUndefined(block.number) && block.number >= 0 && !_.isUndefined(block.difficulty) && !_.isUndefined(block.totalDifficulty) )
|
||||||
{
|
{
|
||||||
block.difficulty = block.difficulty.toString(10);
|
block.difficulty = block.difficulty.toString(10);
|
||||||
block.totalDifficulty = block.totalDifficulty.toString(10);
|
block.totalDifficulty = block.totalDifficulty.toString(10);
|
||||||
@ -629,7 +631,10 @@ Node.prototype.sendStatsUpdate = function (force)
|
|||||||
Node.prototype.ping = function()
|
Node.prototype.ping = function()
|
||||||
{
|
{
|
||||||
this._latency = _.now();
|
this._latency = _.now();
|
||||||
socket.emit('node-ping', { id: this.id });
|
socket.emit('node-ping', {
|
||||||
|
id: this.id,
|
||||||
|
clientTime: _.now()
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Node.prototype.setWatches = function()
|
Node.prototype.setWatches = function()
|
||||||
|
Loading…
Reference in New Issue
Block a user