fixed out of bitcoins; cleanup

This commit is contained in:
Josh Harvey 2014-04-26 23:13:58 -04:00
parent 96f480a73c
commit 30084617c3
3 changed files with 27 additions and 21 deletions

View file

@ -34,14 +34,14 @@ PostgresqlInterface.prototype.summonTransaction =
if (err && PG_ERRORS[err.code] === 'uniqueViolation')
return self._fetchTransaction(tx.txId, cb);
if (err) return cb(err);
cb(null, true);
cb();
});
};
PostgresqlInterface.prototype.reportTransactionError =
function reportTransactionError(tx, err) {
function reportTransactionError(tx, errString, status) {
this.client.query('UPDATE transactions SET status=$1, error=$2 WHERE id=$3',
['failed', err.message, tx.txId]);
[status, errString, tx.txId]);
};
PostgresqlInterface.prototype.completeTransaction =
@ -56,7 +56,7 @@ PostgresqlInterface.prototype.completeTransaction =
PostgresqlInterface.prototype._fetchTransaction =
function _fetchTransaction(txId, cb) {
this.client.query('SELECT status, tx_hash FROM transactions WHERE id=$1',
this.client.query('SELECT status, tx_hash, error FROM transactions WHERE id=$1',
[txId], function (err, results) {
if (err) return cb(err);
@ -64,6 +64,6 @@ PostgresqlInterface.prototype._fetchTransaction =
if (results.rows.length === 0) return cb(new Error('Couldn\'t find transaction.'));
var result = results.rows[0];
cb(null, false, result.tx_hash);
cb(null, {txHash: result.tx_hash, err: result.error, status: result.status});
});
};