mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-01 09:35:48 +00:00
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', ...);
This commit is contained in:
@@ -234,11 +234,15 @@ Request.prototype.books = function (books) {
|
|||||||
// 'connected'
|
// 'connected'
|
||||||
// 'disconnected'
|
// 'disconnected'
|
||||||
// 'state':
|
// 'state':
|
||||||
// - 'online' : connected and subscribed
|
// - 'online' : Connected and subscribed.
|
||||||
// - 'offline' : not subscribed or not connected.
|
// - 'offline' : Not subscribed or not connected.
|
||||||
// 'ledger_closed': A good indicate of ready to serve.
|
|
||||||
// 'subscribed' : This indicates stand-alone is available.
|
// '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
|
// --> trusted: truthy, if remote is trusted
|
||||||
var Remote = function (opts, trace) {
|
var Remote = function (opts, trace) {
|
||||||
@@ -309,7 +313,7 @@ var Remote = function (opts, trace) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.on('newListener', function (type, listener) {
|
this.on('newListener', function (type, listener) {
|
||||||
if ('transaction' === type)
|
if ('transaction_all' === type)
|
||||||
{
|
{
|
||||||
if (!self._transaction_subs && 'open' === self._online_state)
|
if (!self._transaction_subs && 'open' === self._online_state)
|
||||||
{
|
{
|
||||||
@@ -322,7 +326,7 @@ var Remote = function (opts, trace) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('removeListener', function (type, listener) {
|
this.on('removeListener', function (type, listener) {
|
||||||
if ('transaction' === type)
|
if ('transaction_all' === type)
|
||||||
{
|
{
|
||||||
self._transaction_subs -= 1;
|
self._transaction_subs -= 1;
|
||||||
|
|
||||||
@@ -643,6 +647,7 @@ Remote.prototype._connect_message = function (ws, json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.emit('transaction', message);
|
this.emit('transaction', message);
|
||||||
|
this.emit('transaction_all', message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'serverStatus':
|
case 'serverStatus':
|
||||||
|
|||||||
Reference in New Issue
Block a user