Revert "Update pathfind command arguments"

This reverts commit 0753d9cf4a.
This commit is contained in:
wltsmrz
2013-09-17 15:26:37 -07:00
parent 0753d9cf4a
commit 7b4182b322
2 changed files with 27 additions and 34 deletions

View File

@@ -9,18 +9,16 @@ var extend = require('extend');
* Only one path find request is allowed per connection, so when another path * Only one path find request is allowed per connection, so when another path
* find request is triggered it will supercede the existing one, making it emit * find request is triggered it will supercede the existing one, making it emit
* the 'end' and 'superceded' events. * the 'end' and 'superceded' events.
*
* Options:
* src_account
* dst_account
* dst_amount,
* src_currencies
*/ */
function PathFind(remote, src_account, dst_account, dst_amount, src_currencies) {
function PathFind(remote, options) {
EventEmitter.call(this); EventEmitter.call(this);
this.remote = remote;
this.path_options = options; this.remote = remote;
this.src_account = src_account;
this.dst_account = dst_account;
this.dst_amount = dst_amount;
this.src_currencies = src_currencies;
}; };
util.inherits(PathFind, EventEmitter); util.inherits(PathFind, EventEmitter);
@@ -37,7 +35,11 @@ util.inherits(PathFind, EventEmitter);
PathFind.prototype.create = function () { PathFind.prototype.create = function () {
var self = this; var self = this;
var req = this.remote.request_path_find_create(this.path_options, handleInitialPath); var req = this.remote.request_path_find_create(this.src_account,
this.dst_account,
this.dst_amount,
this.src_currencies,
handleInitialPath);
function handleInitialPath(err, msg) { function handleInitialPath(err, msg) {
if (err) { if (err) {

View File

@@ -1083,20 +1083,15 @@ Remote.prototype.account = function (accountID) {
}; };
Remote.prototype.path_find = function (src_account, dst_account, dst_amount, src_currencies) { Remote.prototype.path_find = function (src_account, dst_account, dst_amount, src_currencies) {
var options;
if (typeof src_account === 'object') { if (typeof src_account === 'object') {
options = src_account; var options = src_account;
} else { src_currencies = options.src_currencies;
options = { dst_amount = options.dst_amount;
src_currencies : options.src_currencies, dst_account = options.dst_account;
dst_amount : options.dst_amount, src_account = options.src_account;
dst_account : options.dst_account || options.destination || options.to,
src_account : options.src_account || options.source || options.from
}
} }
var path_find = new PathFind(this, options); var path_find = new PathFind(this, src_account, dst_account, dst_amount, src_currencies);
if (this._cur_path_find) { if (this._cur_path_find) {
this._cur_path_find.notify_superceded(); this._cur_path_find.notify_superceded();
@@ -1282,10 +1277,6 @@ Remote.prototype.request_ripple_balance = function (account, issuer, currency, l
Remote.prepare_currencies = function(ci) { Remote.prepare_currencies = function(ci) {
var ci_new = { }; var ci_new = { };
if (typeof ci === 'string') {
ci = { currency: ci }
}
if (ci.hasOwnProperty('issuer')) { if (ci.hasOwnProperty('issuer')) {
ci_new.issuer = UInt160.json_rewrite(ci.issuer); ci_new.issuer = UInt160.json_rewrite(ci.issuer);
} }
@@ -1301,10 +1292,10 @@ Remote.prototype.request_ripple_path_find = function (src_account, dst_account,
if (typeof src_account === 'object') { if (typeof src_account === 'object') {
var options = src_account; var options = src_account;
callback = dst_account; callback = dst_account;
src_currencies = options.src_currencies || options.currencies; src_currencies = options.src_currencies;
dst_amount = options.dst_amount || options.amount; dst_amount = options.dst_amount;
dst_account = options.dst_account || options.destination || options.to; dst_account = options.dst_account;
src_account = options.src_account || options.source || options.from; src_account = options.src_account;
} }
var request = new Request(this, 'ripple_path_find'); var request = new Request(this, 'ripple_path_find');
@@ -1326,10 +1317,10 @@ Remote.prototype.request_path_find_create = function (src_account, dst_account,
if (typeof src_account === 'object') { if (typeof src_account === 'object') {
var options = src_account; var options = src_account;
callback = dst_account; callback = dst_account;
src_currencies = options.src_currencies || options.currencies; src_currencies = options.src_currencies;
dst_amount = options.dst_amount || options.amount; dst_amount = options.dst_amount;
dst_account = options.dst_account || options.destination || options.to; dst_account = options.dst_account;
src_account = options.src_account || options.source || options.from; src_account = options.src_account;
} }
var request = new Request(this, 'path_find'); var request = new Request(this, 'path_find');