style(whitespace): trailing whitespaces removed
This commit is contained in:
parent
7ab3152e9c
commit
2b64f35689
6 changed files with 22 additions and 22 deletions
|
|
@ -20,16 +20,16 @@ var PostgresqlInterface = function (conString) {
|
|||
PostgresqlInterface.factory = function factory(conString) { return new PostgresqlInterface(conString); };
|
||||
module.exports = PostgresqlInterface;
|
||||
|
||||
PostgresqlInterface.prototype.summonTransaction =
|
||||
PostgresqlInterface.prototype.summonTransaction =
|
||||
function summonTransaction(deviceFingerprint, tx, cb) {
|
||||
// First do an INSERT
|
||||
// If it worked, go ahead with transaction
|
||||
// If duplicate, fetch status and return
|
||||
var self = this;
|
||||
this.client.query('INSERT INTO transactions (id, status, device_fingerprint, ' +
|
||||
'to_address, satoshis, currency_code, fiat) ' +
|
||||
'to_address, satoshis, currency_code, fiat) ' +
|
||||
'VALUES ($1, $2, $3, $4, $5, $6, $7)', [tx.txId, 'pending', deviceFingerprint,
|
||||
tx.toAddress, tx.satoshis, tx.currencyCode, tx.fiat],
|
||||
tx.toAddress, tx.satoshis, tx.currencyCode, tx.fiat],
|
||||
function (err) {
|
||||
if (err && PG_ERRORS[err.code] === 'uniqueViolation')
|
||||
return self._fetchTransaction(tx.txId, cb);
|
||||
|
|
@ -38,30 +38,30 @@ PostgresqlInterface.prototype.summonTransaction =
|
|||
});
|
||||
};
|
||||
|
||||
PostgresqlInterface.prototype.reportTransactionError =
|
||||
PostgresqlInterface.prototype.reportTransactionError =
|
||||
function reportTransactionError(tx, errString, status) {
|
||||
this.client.query('UPDATE transactions SET status=$1, error=$2 WHERE id=$3',
|
||||
this.client.query('UPDATE transactions SET status=$1, error=$2 WHERE id=$3',
|
||||
[status, errString, tx.txId]);
|
||||
};
|
||||
|
||||
PostgresqlInterface.prototype.completeTransaction =
|
||||
PostgresqlInterface.prototype.completeTransaction =
|
||||
function completeTransaction(tx, txHash) {
|
||||
if (txHash)
|
||||
this.client.query('UPDATE transactions SET tx_hash=$1, status=$2, completed=now() WHERE id=$3',
|
||||
this.client.query('UPDATE transactions SET tx_hash=$1, status=$2, completed=now() WHERE id=$3',
|
||||
[txHash, 'completed', tx.txId]);
|
||||
else
|
||||
this.client.query('UPDATE transactions SET status=$1, error=$2 WHERE id=$3',
|
||||
['failed', 'No txHash received', tx.txId]);
|
||||
this.client.query('UPDATE transactions SET status=$1, error=$2 WHERE id=$3',
|
||||
['failed', 'No txHash received', tx.txId]);
|
||||
};
|
||||
|
||||
PostgresqlInterface.prototype._fetchTransaction =
|
||||
PostgresqlInterface.prototype._fetchTransaction =
|
||||
function _fetchTransaction(txId, cb) {
|
||||
this.client.query('SELECT status, tx_hash, error FROM transactions WHERE id=$1',
|
||||
[txId], function (err, results) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// This should never happen, since we already checked for existence
|
||||
if (results.rows.length === 0) return cb(new Error('Couldn\'t find transaction.'));
|
||||
if (results.rows.length === 0) return cb(new Error('Couldn\'t find transaction.'));
|
||||
|
||||
var result = results.rows[0];
|
||||
cb(null, {txHash: result.tx_hash, err: result.error, status: result.status});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue