From c3b41ccbda1bc3126a8fc5ecd36df478ece67eb2 Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 18 Feb 2015 04:32:03 +0200 Subject: [PATCH] fixed socket ready event --- lib/node.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/node.js b/lib/node.js index 23c86b4..934c5a0 100644 --- a/lib/node.js +++ b/lib/node.js @@ -85,11 +85,8 @@ function Node() 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.'); }) @@ -105,25 +102,30 @@ Node.prototype.isActive = function() this.stats.errors = []; try { - this.stats.peers = web3.eth.peerCount; - this.stats.active = true; + var peers = web3.eth.peerCount; - return true; + if(peers !== null) + { + this.stats.peers = peers; + this.stats.active = true; + + return true; + } } catch (err) { - this.stats.active = false; - this.stats.listening = false; - this.stats.mining = false; - this.stats.peers = 0; - this._down++; - this.stats.errors.push({ code: '1', 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)