diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-14 17:50:34 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-14 17:50:34 +0800 |
commit | 8d1f96cc0aa608c319a48af5a3c2397b694d5930 (patch) | |
tree | 1907976796469318b9be61df0f0d1978c76975ec /lib/autoprovider.js | |
parent | 422dc05bb054b86d72b313edc2e7cb79dfb70ba3 (diff) | |
download | go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.gz go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.bz2 go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.lz go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.xz go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.zst go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.zip |
few comments
Diffstat (limited to 'lib/autoprovider.js')
-rw-r--r-- | lib/autoprovider.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/autoprovider.js b/lib/autoprovider.js index 113873674..8460a144f 100644 --- a/lib/autoprovider.js +++ b/lib/autoprovider.js @@ -33,6 +33,13 @@ if (process.env.NODE_ENV !== 'build') { var web3 = require('./web3'); // jshint ignore:line } +/// Automatically tries to setup correct provider +/// First it checkes if we are ethereum browser (if navigator.qt object is available) +/// if yes, we are using QtProvider +/// if no, we check if it is possible to establish websockets connection with ethereum (ws://localhost:40404/eth is default) +/// if it's not possible, we are using httprpc provider (http://localhost:8080) +/// The constructor allows you to specify uris on which we are trying to connect over http or websockets +/// You can do that by passing objects with fields httrpc and websockets var AutoProvider = function (userOptions) { if (web3.haveProvider()) { return; @@ -81,6 +88,8 @@ var AutoProvider = function (userOptions) { }; }; +/// Sends message forward to the provider, that is being used +/// if provider is not yet set, enqueues the message AutoProvider.prototype.send = function (payload) { if (this.provider) { this.provider.send(payload); @@ -89,6 +98,7 @@ AutoProvider.prototype.send = function (payload) { this.sendQueue.push(payload); }; +/// On incoming message sends the message to the provider that is currently being used Object.defineProperty(AutoProvider.prototype, 'onmessage', { set: function (handler) { if (this.provider) { |