From a4138189897b41b76c0b5ab5f5141ed1c7db16b9 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Wed, 6 Mar 2013 21:52:48 +0100 Subject: [PATCH] JS: Don't trigger global subscribe for remote.on('transaction'). Now that all transactions we're subscribed to for any reason come in via `type: transaction"`, users may need to subscribe to these events without triggering a subscription to all transactions network-wide. So if you were subscribing to the network-wide transaction firehose via: remote.on('transaction', ...); Please change this to: remote.on('transaction_all', ...); --- src/js/remote.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/js/remote.js b/src/js/remote.js index 8805ee654..fa9e4ba51 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -234,11 +234,15 @@ Request.prototype.books = function (books) { // 'connected' // 'disconnected' // 'state': -// - 'online' : connected and subscribed -// - 'offline' : not subscribed or not connected. -// 'ledger_closed': A good indicate of ready to serve. -// 'subscribed' : This indicates stand-alone is available. +// - 'online' : Connected and subscribed. +// - 'offline' : Not subscribed or not connected. +// 'subscribed' : This indicates stand-alone is available. // +// Server events: +// 'ledger_closed' : A good indicate of ready to serve. +// 'transaction' : Transactions we receive based on current subscriptions. +// 'transaction_all' : Listening triggers a subscribe to all transactions +// globally in the network. // --> trusted: truthy, if remote is trusted var Remote = function (opts, trace) { @@ -309,7 +313,7 @@ var Remote = function (opts, trace) { }; this.on('newListener', function (type, listener) { - if ('transaction' === type) + if ('transaction_all' === type) { if (!self._transaction_subs && 'open' === self._online_state) { @@ -322,7 +326,7 @@ var Remote = function (opts, trace) { }); this.on('removeListener', function (type, listener) { - if ('transaction' === type) + if ('transaction_all' === type) { self._transaction_subs -= 1; @@ -643,6 +647,7 @@ Remote.prototype._connect_message = function (ws, json) { } this.emit('transaction', message); + this.emit('transaction_all', message); break; case 'serverStatus':