From f87a378b4d51827ab71188a5e3cf7c84e5aeaff5 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 3 Apr 2015 19:34:31 +0300 Subject: [PATCH] added debounce to 'latest' filter --- lib/node.js | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index 88be379..5c7bf97 100644 --- a/lib/node.js +++ b/lib/node.js @@ -2,6 +2,7 @@ var web3 = require('ethereum.js'); var _ = require('lodash'); var os = require('os'); var shelljs = require('shelljs'); +var debounce = require('debounce'); var Primus = require('primus'), Emitter = require('primus-emit'), @@ -386,7 +387,9 @@ Node.prototype.setWatches = function() this.chainFilter = web3.eth.filter('latest'); this.chainFilter.watch(function(log) { - self.update(); + debounce(function() { + self.update(); + }, 50); }); this.updateInterval = setInterval(function(){ diff --git a/package.json b/package.json index ead35a2..5ffd9eb 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "lib": "./lib" }, "dependencies": { + "debounce": "^1.0.0", "debug": "~2.1.3", "ethereum.js": "0.2.4", "lodash": "^3.6.0",