From d43bc13f48a8ced6a21cda3d016aae39faa67aba Mon Sep 17 00:00:00 2001 From: wltsmrz Date: Tue, 3 Sep 2013 15:28:32 -0700 Subject: [PATCH] request.set_server(string) selects by host --- src/js/ripple/request.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/js/ripple/request.js b/src/js/ripple/request.js index e31b6b39..4a6fccbe 100644 --- a/src/js/ripple/request.js +++ b/src/js/ripple/request.js @@ -90,7 +90,23 @@ Request.prototype.timeout = function(duration, callback) { }; Request.prototype.set_server = function(server) { - this.server = server; + var selected = null; + + switch (typeof server) { + case 'object': + selected = server; + break; + case 'string': + for (var i=0, s; s=this.remote._servers[i]; i++) { + if (s._host === server) { + selected = s; + break; + } + } + break; + }; + + this.server = selected; }; Request.prototype.build_path = function (build) { @@ -214,7 +230,7 @@ Request.prototype.accounts = function (accounts, realtime) { var processedAccounts = accounts.map(function(account) { return UInt160.json_rewrite(account); }); - + if (realtime) { this.message.rt_accounts = processedAccounts; } else { @@ -243,7 +259,6 @@ Request.prototype.books = function (books, snapshot) { var obj = json[side] = { currency: Currency.json_rewrite(book[side].currency) }; - if (obj.currency !== 'XRP') { obj.issuer = UInt160.json_rewrite(book[side].issuer); } @@ -257,7 +272,7 @@ Request.prototype.books = function (books, snapshot) { } if (book.both) { - json.both = true; + json.both = true; } processedBooks.push(json);