diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-02-04 04:43:39 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-02-04 04:43:39 +0800 |
commit | f3ce1f07c42924a116e9c215ea95fb0a2b0217f0 (patch) | |
tree | 0c37c6ba414463648b33811832b90e84530f6ff1 /lib/providermanager.js | |
parent | ddc17196da36c1ad660b70f33f8b4eaaccdbdda8 (diff) | |
download | dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar.gz dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar.bz2 dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar.lz dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar.xz dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.tar.zst dexon-f3ce1f07c42924a116e9c215ea95fb0a2b0217f0.zip |
simplified polling && jsonrpc payload creation
Diffstat (limited to 'lib/providermanager.js')
-rw-r--r-- | lib/providermanager.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/providermanager.js b/lib/providermanager.js index 25cd14288..38c0f6c46 100644 --- a/lib/providermanager.js +++ b/lib/providermanager.js @@ -43,18 +43,14 @@ var ProviderManager = function() { var poll = function () { if (self.provider) { self.polls.forEach(function (data) { - data.data._id = self.id; - self.id++; - var result = self.provider.send(data.data); + var result = self.send(data.data); - result = JSON.parse(result); - // dont call the callback if result is not an array, or empty one - if (result.error || !(result.result instanceof Array) || result.result.length === 0) { + if (!(result instanceof Array) || result.length === 0) { return; } - data.callback(result.result); + data.callback(result); }); } setTimeout(poll, 1000); @@ -63,10 +59,12 @@ var ProviderManager = function() { }; /// sends outgoing requests +/// @params data - an object with at least 'method' property ProviderManager.prototype.send = function(data) { - data.args = data.args || []; - data._id = this.id++; + data.jsonrpc = '2.0'; + data.params = data.params || []; + data.id = this.id++; if (this.provider === undefined) { console.error('provider is not set'); |