From 019507a44f944960f06940873f51334a87cc43b6 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 5 May 2015 01:00:01 +0300 Subject: [PATCH] re-added pending filter --- lib/node.js | 57 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/node.js b/lib/node.js index 9654e9d..82b8fcc 100644 --- a/lib/node.js +++ b/lib/node.js @@ -542,8 +542,6 @@ Node.prototype.updateBlock = function() { this.getStatsBlock(); - this.update(true); - return this; }; @@ -613,34 +611,34 @@ Node.prototype.setWatches = function() console.error(err); } - // try { - // this.pendingFilter = web3.eth.filter('pending'); - // this.pendingFilter.watch( function (log) - // { - // var now = _.now(); - // var time = now - self._lastPendingLog; + try { + this.pendingFilter = web3.eth.filter('pending'); + this.pendingFilter.watch( function (log) + { + var now = _.now(); + var time = now - self._lastPendingLog; - // console.log('>>> Pending Filter triggered: ', now); + console.log('>>> Pending Filter triggered: ', now); - // if(time > 50) - // { - // self.update(); - // } - // else - // { - // debounce(function() { - // self.update(); - // }, 50); - // } + if(time > 50) + { + self.update(true); + } + else + { + debounce(function() { + self.update(true); + }, 50); + } - // self._lastPendingLog = now; - // }); - // } - // catch (err) - // { - // console.error("Couldn't set up pending filter"); - // console.error(err); - // } + self._lastPendingLog = now; + }); + } + catch (err) + { + console.error("Couldn't set up pending filter"); + console.error(err); + } this.updateInterval = setInterval( function(){ self.update(); @@ -678,8 +676,11 @@ Node.prototype.init = function() // Set filters this.setWatches(); - // Update stats and send info + // Update block and send info this.updateBlock(); + + // Update stats and send info + this.update(); } Node.prototype.stop = function()