diff --git a/src/js/ripple/account.js b/src/js/ripple/account.js index d8ef4d36..96657e57 100644 --- a/src/js/ripple/account.js +++ b/src/js/ripple/account.js @@ -61,7 +61,7 @@ function Account(remote, account) { this.on('removeListener', listener_removed); function prepare_subscribe(request) { - if (self._subs) { + if (self._account.is_valid() && self._subs) { request.accounts(self._account_id); } } diff --git a/src/js/ripple/pathfind.js b/src/js/ripple/pathfind.js index 3c456140..dc83bb34 100644 --- a/src/js/ripple/pathfind.js +++ b/src/js/ripple/pathfind.js @@ -48,12 +48,15 @@ PathFind.prototype.create = function () function handleInitialPath(err, msg) { if (err) { - // XXX Handle error + self.emit('error', err); return; } self.notify_update(msg); } + // XXX We should add ourselves to prepare_subscribe or a similar mechanism so + // that we can resubscribe after a reconnection. + req.request(); }; @@ -81,6 +84,9 @@ PathFind.prototype.notify_update = function (message) PathFind.prototype.notify_superceded = function () { + // XXX If we're set to re-subscribe whenever we connect to a new server, then + // we should cancel that behavior here. See PathFind#create. + this.emit('end'); this.emit('superceded'); }; diff --git a/src/js/ripple/remote.js b/src/js/ripple/remote.js index 2319c628..bae035b7 100644 --- a/src/js/ripple/remote.js +++ b/src/js/ripple/remote.js @@ -963,6 +963,11 @@ Remote.prototype._server_prepare_subscribe = function (callback) { self.emit('subscribed'); }); + request.on('error', function (err) { + // XXX We need a better global error handling + console.log(err); + }); + self.emit('prepare_subscribe', request); request.callback(callback); diff --git a/src/js/ripple/serializedtypes.js b/src/js/ripple/serializedtypes.js index 578e570f..ce8a3f1f 100644 --- a/src/js/ripple/serializedtypes.js +++ b/src/js/ripple/serializedtypes.js @@ -374,6 +374,9 @@ var STVL = exports.VariableLength = new SerializedType({ var STAccount = exports.Account = new SerializedType({ serialize: function (so, val) { var account = UInt160.from_json(val); + if (!account.is_valid()) { + throw new Error("Invalid account!"); + } serialize_hex(so, account.to_hex()); }, parse: function (so) {