fixed socket ready event

This commit is contained in:
cubedro 2015-02-18 04:32:03 +02:00
parent a019d77205
commit c3b41ccbda

View File

@ -85,11 +85,8 @@ function Node()
socket.on('ready', function() socket.on('ready', function()
{ {
if(self.changed()) self._socket = true;
{ self.sendUpdate(true);
self._socket = true;
self.sendUpdate(true);
}
console.log('The connection has been established.'); console.log('The connection has been established.');
}) })
@ -105,25 +102,30 @@ Node.prototype.isActive = function()
this.stats.errors = []; this.stats.errors = [];
try { try {
this.stats.peers = web3.eth.peerCount; var peers = web3.eth.peerCount;
this.stats.active = true;
return true; if(peers !== null)
{
this.stats.peers = peers;
this.stats.active = true;
return true;
}
} }
catch (err) { catch (err) {
this.stats.active = false;
this.stats.listening = false;
this.stats.mining = false;
this.stats.peers = 0;
this._down++;
this.stats.errors.push({ this.stats.errors.push({
code: '1', code: '1',
msg: err msg: err
}); });
return false;
} }
this.stats.active = false;
this.stats.listening = false;
this.stats.mining = false;
this.stats.peers = 0;
this._down++;
return false;
} }
Node.prototype.getBlock = function(number) Node.prototype.getBlock = function(number)