Merge branch 'develop' of https://github.com/ripple/ripple-lib into develop

This commit is contained in:
wltsmrz
2013-08-22 10:55:16 -07:00
4 changed files with 16 additions and 2 deletions

View File

@@ -61,7 +61,7 @@ function Account(remote, account) {
this.on('removeListener', listener_removed); this.on('removeListener', listener_removed);
function prepare_subscribe(request) { function prepare_subscribe(request) {
if (self._subs) { if (self._account.is_valid() && self._subs) {
request.accounts(self._account_id); request.accounts(self._account_id);
} }
} }

View File

@@ -48,12 +48,15 @@ PathFind.prototype.create = function ()
function handleInitialPath(err, msg) { function handleInitialPath(err, msg) {
if (err) { if (err) {
// XXX Handle error self.emit('error', err);
return; return;
} }
self.notify_update(msg); 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(); req.request();
}; };
@@ -81,6 +84,9 @@ PathFind.prototype.notify_update = function (message)
PathFind.prototype.notify_superceded = function () 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('end');
this.emit('superceded'); this.emit('superceded');
}; };

View File

@@ -963,6 +963,11 @@ Remote.prototype._server_prepare_subscribe = function (callback) {
self.emit('subscribed'); self.emit('subscribed');
}); });
request.on('error', function (err) {
// XXX We need a better global error handling
console.log(err);
});
self.emit('prepare_subscribe', request); self.emit('prepare_subscribe', request);
request.callback(callback); request.callback(callback);

View File

@@ -374,6 +374,9 @@ var STVL = exports.VariableLength = new SerializedType({
var STAccount = exports.Account = new SerializedType({ var STAccount = exports.Account = new SerializedType({
serialize: function (so, val) { serialize: function (so, val) {
var account = UInt160.from_json(val); var account = UInt160.from_json(val);
if (!account.is_valid()) {
throw new Error("Invalid account!");
}
serialize_hex(so, account.to_hex()); serialize_hex(so, account.to_hex());
}, },
parse: function (so) { parse: function (so) {