added chain filter dobounce

This commit is contained in:
cubedro 2015-06-02 00:49:25 +03:00
parent 092f859e60
commit 3e82d5aad5
1 changed files with 19 additions and 1 deletions

View File

@ -105,6 +105,7 @@ function Node ()
this._socket = false;
this._latestQueue = null;
this._chainDebouncer = 0;
this.pendingFilter = false;
this.chainFilter = false;
this.updateInterval = false;
@ -666,7 +667,24 @@ Node.prototype.setWatches = function()
console.info('>>>', 'Chain Filter triggered: ', chalk.reset.red(hash), '- last trigger:', chalk.reset.cyan(time));
self._latestQueue.push(hash);
if(time < 5)
{
this._chainDebouncer++;
} else {
this._chainDebouncer = 0;
}
if(this._chainDebouncer < 20)
{
self._latestQueue.push(hash);
}
else
{
debounce(function() {
self._latestQueue.push(hash);
self._chainDebouncer = 0;
}, 5);
}
});
console.success("Installed chain filter");