diff --git a/lib/node.js b/lib/node.js index 8e94806..09c3d75 100644 --- a/lib/node.js +++ b/lib/node.js @@ -354,9 +354,6 @@ Node.prototype.getLatestBlock = function () { var self = this; - if(this._socket) - this._lastStats = JSON.stringify(this.stats); - if(this._web3) { var timeString = 'Got block in' + chalk.reset.red(''); @@ -399,7 +396,7 @@ Node.prototype.validateLatestBlock = function (error, result, timeString) console.success("==>", "Got block:", chalk.reset.red(block.number)); this.stats.block = block; - this.sendUpdate(); + this.sendBlockUpdate(); if(this.stats.block.number - this._lastBlock > 1) { @@ -480,7 +477,7 @@ Node.prototype.getStats = function(forced) self.setUptime(); - self.sendUpdate(); + self.sendUpdate(forced); }); } } @@ -490,9 +487,6 @@ Node.prototype.getPending = function() var self = this; var now = _.now(); - if (this._socket) - this._lastStats = JSON.stringify(this.stats); - if (this._web3) { console.info('==>', 'Getting Pending') @@ -620,6 +614,12 @@ Node.prototype.sendUpdate = function (force) } } +Node.prototype.sendBlockUpdate = function() +{ + console.info("wsc", "Sending", chalk.reset.red("block"), chalk.bold.white("update")); + this.emit('block', this.prepareBlock()); +} + Node.prototype.sendPendingUpdate = function() { if( this.changed() ) {