This commit is contained in:
wltsmrz
2014-04-17 15:19:08 -07:00
parent 969873441e
commit 8ffd0b13a3
3 changed files with 95 additions and 90 deletions

View File

@@ -239,20 +239,20 @@ function Remote(opts, trace) {
self.storage.getPendingTransactions(function(err, transactions) {
if (err || !Array.isArray(transactions)) return;
var properties = [
'submittedIDs',
'clientID',
'submitIndex'
];
function resubmitTransaction(tx) {
var transaction = self.transaction();
transaction.parseJson(tx.tx_json);
properties.forEach(function(prop) {
if (typeof tx[prop] !== 'undefined') {
transaction[prop] = tx[prop];
Object.keys(tx).forEach(function(prop) {
switch (prop) {
case 'submittedIDs':
case 'clientID':
case 'submitIndex':
transaction[prop] = tx[prop];
break;
}
});
transaction.submit();
};
@@ -344,16 +344,16 @@ Remote.prototype.addServer = function(opts) {
server.on('message', serverMessage);
function serverConnect() {
self._connection_count += 1;
if (opts.primary || !self._primary_server) {
self._setPrimaryServer(server);
}
switch (++self._connection_count) {
case 1:
self._setState('online');
break;
case self._servers.length:
self.emit('ready');
break;
if (self._connection_count === 1) {
self._setState('online');
}
if (self._connection_count === self._servers.length) {
self.emit('ready');
}
};
@@ -699,20 +699,18 @@ Remote.prototype.requestLedger = function(ledger, options, callback) {
request.message.ledger = ledger;
}
var requestFields = [
'full',
'expand',
'transactions',
'accounts'
];
switch (typeof options) {
case 'object':
for (var key in options) {
if (~requestFields.indexOf(key)) {
request.message[key] = true;
Object.keys(options).forEach(function(o) {
switch (o) {
case 'full':
case 'expand':
case 'transactions':
case 'accounts':
request.message[o] = true;
break;
}
}
}, options);
break;
case 'function':
@@ -732,7 +730,7 @@ Remote.prototype.requestLedger = function(ledger, options, callback) {
return request;
};
// Only for unit testing.
Remote.prototype.requestLedgerClosed =
Remote.prototype.requestLedgerHash = function(callback) {
//utils.assert(this.trusted); // If not trusted, need to check proof.
return new Request(this, 'ledger_closed').callback(callback);
@@ -975,26 +973,24 @@ Remote.prototype.requestAccountTx = function(options, callback) {
var request = new Request(this, 'account_tx');
var requestFields = [
'account',
'ledger_index_min', //earliest
'ledger_index_max', //latest
'binary', //false
'count', //false
'descending', //false
'offset', //0
'limit',
Object.keys(options).forEach(function(o) {
switch (o) {
case 'account':
case 'ledger_index_min': //earliest
case 'ledger_index_max': //latest
case 'binary': //false
case 'count': //false
case 'descending': //false
case 'offset': //0
case 'limit':
//extended account_tx
'forward', //false
'marker'
];
for (var key in options) {
if (~requestFields.indexOf(key)) {
request.message[key] = options[key];
//extended account_tx
case 'forward': //false
case 'marker':
request.message[o] = this[o];
break;
}
}
}, options);
function propertiesFilter(obj, transaction) {
var properties = Object.keys(obj);
@@ -1259,6 +1255,7 @@ Remote.accountRootRequest = function(type, responseFilter, account, ledger, call
}
var request = this.requestLedgerEntry('account_root');
request.accountRoot(account);
request.ledgerChoose(ledger);