Added pollingInterval to provider. (#132)
This commit is contained in:
parent
5a9f440c8f
commit
46fd2deb8b
27
dist/ethers-providers.js
vendored
27
dist/ethers-providers.js
vendored
@ -4187,8 +4187,8 @@ utils.defineProperty(EtherscanProvider.prototype, 'getHistory', function(address
|
||||
|
||||
return this.resolveName(addressOrName).then(function(address) {
|
||||
url += '/api?module=account&action=txlist&address=' + address;
|
||||
url += '&fromBlock=' + startBlock;
|
||||
url += '&endBlock=' + endBlock;
|
||||
url += '&startblock=' + startBlock;
|
||||
url += '&endblock=' + endBlock;
|
||||
url += '&sort=asc';
|
||||
|
||||
return Provider.fetchJSON(url, null, getResult).then(function(result) {
|
||||
@ -5081,13 +5081,15 @@ function Provider(network) {
|
||||
self.doPoll();
|
||||
});
|
||||
|
||||
var pollingInterval = 4000;
|
||||
|
||||
var poller = null;
|
||||
Object.defineProperty(this, 'polling', {
|
||||
get: function() { return (poller != null); },
|
||||
set: function(value) {
|
||||
setTimeout(function() {
|
||||
if (value && !poller) {
|
||||
poller = setInterval(doPoll, 4000);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
|
||||
} else if (!value && poller) {
|
||||
clearInterval(poller);
|
||||
@ -5096,6 +5098,25 @@ function Provider(network) {
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'pollingInterval', {
|
||||
get: function() { return pollingInterval; },
|
||||
set: function(value) {
|
||||
if (typeof(value) !== 'number' || value <= 0 || parseInt(value) != value) {
|
||||
throw new Error('invalid polling interval');
|
||||
}
|
||||
|
||||
pollingInterval = value;
|
||||
|
||||
if (poller) {
|
||||
clearInterval(poller);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
}
|
||||
|
||||
function inheritable(parent) {
|
||||
|
4
dist/ethers-providers.min.js
vendored
4
dist/ethers-providers.min.js
vendored
File diff suppressed because one or more lines are too long
29
dist/ethers.js
vendored
29
dist/ethers.js
vendored
@ -9568,7 +9568,7 @@ uuid.unparse = unparse;
|
||||
module.exports = uuid;
|
||||
|
||||
},{"./rng":43}],45:[function(require,module,exports){
|
||||
module.exports={"version":"3.0.4"}
|
||||
module.exports={"version":"3.0.6"}
|
||||
},{}],46:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
@ -9821,8 +9821,8 @@ utils.defineProperty(EtherscanProvider.prototype, 'getHistory', function(address
|
||||
|
||||
return this.resolveName(addressOrName).then(function(address) {
|
||||
url += '/api?module=account&action=txlist&address=' + address;
|
||||
url += '&fromBlock=' + startBlock;
|
||||
url += '&endBlock=' + endBlock;
|
||||
url += '&startblock=' + startBlock;
|
||||
url += '&endblock=' + endBlock;
|
||||
url += '&sort=asc';
|
||||
|
||||
return Provider.fetchJSON(url, null, getResult).then(function(result) {
|
||||
@ -10715,13 +10715,15 @@ function Provider(network) {
|
||||
self.doPoll();
|
||||
});
|
||||
|
||||
var pollingInterval = 4000;
|
||||
|
||||
var poller = null;
|
||||
Object.defineProperty(this, 'polling', {
|
||||
get: function() { return (poller != null); },
|
||||
set: function(value) {
|
||||
setTimeout(function() {
|
||||
if (value && !poller) {
|
||||
poller = setInterval(doPoll, 4000);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
|
||||
} else if (!value && poller) {
|
||||
clearInterval(poller);
|
||||
@ -10730,6 +10732,25 @@ function Provider(network) {
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'pollingInterval', {
|
||||
get: function() { return pollingInterval; },
|
||||
set: function(value) {
|
||||
if (typeof(value) !== 'number' || value <= 0 || parseInt(value) != value) {
|
||||
throw new Error('invalid polling interval');
|
||||
}
|
||||
|
||||
pollingInterval = value;
|
||||
|
||||
if (poller) {
|
||||
clearInterval(poller);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
}
|
||||
|
||||
function inheritable(parent) {
|
||||
|
6
dist/ethers.min.js
vendored
6
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethers",
|
||||
"version": "3.0.5",
|
||||
"version": "3.0.6",
|
||||
"description": "Ethereum wallet library.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -476,13 +476,15 @@ function Provider(network) {
|
||||
self.doPoll();
|
||||
});
|
||||
|
||||
var pollingInterval = 4000;
|
||||
|
||||
var poller = null;
|
||||
Object.defineProperty(this, 'polling', {
|
||||
get: function() { return (poller != null); },
|
||||
set: function(value) {
|
||||
setTimeout(function() {
|
||||
if (value && !poller) {
|
||||
poller = setInterval(doPoll, 4000);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
|
||||
} else if (!value && poller) {
|
||||
clearInterval(poller);
|
||||
@ -491,6 +493,25 @@ function Provider(network) {
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'pollingInterval', {
|
||||
get: function() { return pollingInterval; },
|
||||
set: function(value) {
|
||||
if (typeof(value) !== 'number' || value <= 0 || parseInt(value) != value) {
|
||||
throw new Error('invalid polling interval');
|
||||
}
|
||||
|
||||
pollingInterval = value;
|
||||
|
||||
if (poller) {
|
||||
clearInterval(poller);
|
||||
poller = setInterval(doPoll, pollingInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
}
|
||||
|
||||
function inheritable(parent) {
|
||||
|
Loading…
Reference in New Issue
Block a user