Persistent transactions interface (Gateway REST API)

This commit is contained in:
wltsmrz
2014-02-28 16:27:09 -08:00
parent 37065123e5
commit 5ed148af75
3 changed files with 76 additions and 71 deletions

View File

@@ -190,17 +190,32 @@ function Remote(opts, trace) {
this.on('removeListener', listenerRemoved);
function addPendingAccounts() {
opts.storage.loadAccounts(function(err, accounts) {
if (!err && Array.isArray(accounts)) {
accounts.forEach(self.account.bind(self));
}
function getPendingTransactions() {
self.storage.getPendingTransactions(function(err, transactions) {
if (err || !Array.isArray(transactions)) return;
var properties = [
'submittedIDs',
'clientID',
'submitIndex'
];
transactions.forEach(function(tx) {
var transaction = self.transaction();
transaction.parseJson(tx.tx_json);
properties.forEach(function(prop) {
if (typeof tx[prop] !== 'undefined') {
transaction[prop] = tx[prop];
}
});
transaction.submit();
});
});
};
if (opts.storage) {
this.storage = opts.storage;
this.once('connect', addPendingAccounts);
this.once('connect', getPendingTransactions);
}
function pingServers() {