diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-22 04:22:05 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-22 04:22:05 +0800 |
commit | 08e26966275d5d0d7186bf734842e5da59a5bec9 (patch) | |
tree | a49e7fb0d5cf9ec06f85fb1d4da9a803ef66dfb6 /lib | |
parent | c9693b47467f16a6f35be6de85f57244b70d7a01 (diff) | |
download | go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar.gz go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar.bz2 go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar.lz go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar.xz go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.tar.zst go-tangerine-08e26966275d5d0d7186bf734842e5da59a5bec9.zip |
removed send queues from providermanager
Diffstat (limited to 'lib')
-rw-r--r-- | lib/providermanager.js | 18 | ||||
-rw-r--r-- | lib/web3.js | 23 |
2 files changed, 12 insertions, 29 deletions
diff --git a/lib/providermanager.js b/lib/providermanager.js index 90e5ee409..c3b121451 100644 --- a/lib/providermanager.js +++ b/lib/providermanager.js @@ -57,17 +57,19 @@ var ProviderManager = function() { /// sends outgoing requests, if provider is not available, enqueue the request ProviderManager.prototype.send = function(data) { - data._id = this.id; data.args = data.args || []; - this.id++; + data._id = this.id++; if (this.provider === undefined) { console.error('provider is not set'); - return JSON.stringify({result: 'error, provider is not set'}); + return undefined; } - return this.provider.send(data); + //TODO: handle error here? + var result = this.provider.send(data); + result = JSON.parse(result); + return result.result; }; /// setups provider, which will be used for sending messages @@ -80,14 +82,6 @@ ProviderManager.prototype.set = function(provider) { this.ready = true; }; -/// resends queued messages -ProviderManager.prototype.sendQueued = function() { - for(var i = 0; this.queued.length; i++) { - // Resend - this.send(this.queued[i]); - } -}; - /// @returns true if the provider i properly set ProviderManager.prototype.installed = function() { return this.provider !== undefined; diff --git a/lib/web3.js b/lib/web3.js index 166bf68de..515c8c37b 100644 --- a/lib/web3.js +++ b/lib/web3.js @@ -129,14 +129,10 @@ var setupMethods = function (obj, methods) { obj[method.name] = function () { var args = Array.prototype.slice.call(arguments); var call = typeof method.call === 'function' ? method.call(args) : method.call; - var result = web3.provider.send({ + return web3.provider.send({ call: call, args: args }); - - result = JSON.parse(result); - return result.result; - }; }); }; @@ -147,24 +143,17 @@ var setupProperties = function (obj, properties) { properties.forEach(function (property) { var proto = {}; proto.get = function () { - var result = web3.provider.send({ + return web3.provider.send({ call: property.getter }); - - result = JSON.parse(result); - return result.result; - }; + if (property.setter) { proto.set = function (val) { - var result = web3.provider.send({ + return web3.provider.send({ call: property.setter, args: [val] }); - - result = JSON.parse(result); - return result.result; - }; } Object.defineProperty(obj, property.name, proto); @@ -172,6 +161,7 @@ var setupProperties = function (obj, properties) { }; // TODO: import from a dependency, don't duplicate. +// TODO: use bignumber for that! var hexToDec = function (hex) { return parseInt(hex, 16).toString(); }; @@ -330,9 +320,8 @@ var shhWatch = { setupMethods(shhWatch, shhWatchMethods()); web3.setProvider = function(provider) { - provider.onmessage = messageHandler; + //provider.onmessage = messageHandler; // there will be no async calls, to remove web3.provider.set(provider); - web3.provider.sendQueued(); }; /// callled when there is new incoming message |