diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-16 00:27:07 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-16 00:27:07 +0800 |
commit | 6d02c0d392762203dc150203ce0f315654aed5c2 (patch) | |
tree | e6c51635dae8245effc9b570de4f8cb00a117b1c /lib/autoprovider.js | |
parent | 508f116738517efc8c21233e9d50349ba30e223c (diff) | |
parent | ec74fc05d438806ece64fe34b0f28c8f45f5167e (diff) | |
download | go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar.gz go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar.bz2 go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar.lz go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar.xz go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.tar.zst go-tangerine-6d02c0d392762203dc150203ce0f315654aed5c2.zip |
Merge commit '1a6dbeff6e86d65cae6d7db366cbaa4182eaff7f' into ethereumjs
Conflicts:
libjsqrc/ethereumjs/dist/ethereum.js
libjsqrc/ethereumjs/dist/ethereum.js.map
libjsqrc/ethereumjs/dist/ethereum.min.js
libjsqrc/ethereumjs/lib/abi.js
Diffstat (limited to 'lib/autoprovider.js')
-rw-r--r-- | lib/autoprovider.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/autoprovider.js b/lib/autoprovider.js index 113873674..a2c265ccb 100644 --- a/lib/autoprovider.js +++ b/lib/autoprovider.js @@ -33,6 +33,16 @@ if (process.env.NODE_ENV !== 'build') { var web3 = require('./web3'); // jshint ignore:line } +/** + * AutoProvider object prototype is implementing 'provider protocol' + * Automatically tries to setup correct provider(Qt, WebSockets or HttpRpc) + * 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 +91,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 +101,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) { |