From 2b64f3568929a7d590244a5c7164fc78f95cce87 Mon Sep 17 00:00:00 2001 From: Damian Mee Date: Tue, 5 Aug 2014 17:21:39 +0200 Subject: [PATCH] style(whitespace): trailing whitespaces removed --- lib/app.js | 4 ++-- lib/postgresql_interface.js | 22 +++++++++++----------- lib/routes.js | 4 ++-- lib/trader.js | 10 +++++----- test/api/sendTest.js | 2 +- test/unit/traderFiatBalanceTest.js | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/app.js b/lib/app.js index 854e0dd8..46241570 100644 --- a/lib/app.js +++ b/lib/app.js @@ -8,7 +8,7 @@ var routes = require('./routes'); var Trader = require('./trader'); var PostgresqlInterface = require('./postgresql_interface'); var logger = require('./logger'); - + module.exports = function (options) { var app = express(); var connectionString; @@ -65,7 +65,7 @@ module.exports = function (options) { config.isAuthorized(routes.getFingerprint(req), function (err, device) { if (err) { res.json({err: 'Internal Server Error'}); - return next(err); + return next(err); } if (!device) { res.json(404, {err: 'Not Found'}); diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index 2b7885eb..f1269445 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -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}); diff --git a/lib/routes.js b/lib/routes.js index 7a162d28..dfd7d6df 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -69,8 +69,8 @@ function send(req, res) { var fingerprint = getFingerprint(req); _trader.sendBitcoins(fingerprint, req.body, function(err, txHash) { res.json({ - err: err && err.message, - txHash: txHash, + err: err && err.message, + txHash: txHash, errType: err && err.name }); }); diff --git a/lib/trader.js b/lib/trader.js index 48d4c5f5..60b1e1c5 100644 --- a/lib/trader.js +++ b/lib/trader.js @@ -103,7 +103,7 @@ Trader.prototype.configure = function (config) { }; // IMPORTANT: This function returns the estimated minimum available balance -// in fiat as of the start of the current user session on the device. User +// in fiat as of the start of the current user session on the device. User // session starts when a user presses then Start button and ends when we // send the bitcoins. Trader.prototype.fiatBalance = function (deviceFingerprint) { @@ -125,7 +125,7 @@ Trader.prototype.fiatBalance = function (deviceFingerprint) { // `balance.transferBalance` is the balance of our transfer account (the one // we use to send Bitcoins to clients) in satoshis. var transferBalance = balance.transferBalance; - + // Since `transferBalance` is in satoshis, we need to turn it into // bitcoins and then fiat to learn how much fiat currency we can exchange. // @@ -193,7 +193,7 @@ Trader.prototype.sendBitcoins = function (deviceFingerprint, tx, cb) { if (txRec.status === 'insufficientFunds') txErr.name = 'InsufficientFunds'; } - // transaction exists, but txHash might be null, + // transaction exists, but txHash might be null, // in which case ATM should continue polling self.pollBalance(); cb(txErr, txRec.txHash); @@ -213,7 +213,7 @@ Trader.prototype.trade = function (rec, deviceFingerprint) { delete self._sessionInfo[deviceFingerprint]; }, SESSION_TIMEOUT) }; - } + } this._tradeQueue.push({fiat: rec.fiat, satoshis: rec.satoshis, currency: rec.currency}); }; @@ -291,7 +291,7 @@ Trader.prototype._tradeForexMultiplier = function _tradeForexMultiplier() { Trader.prototype._tradeBalanceFunc = function _tradeBalanceFunc(callback) { if (!this.tradeExchange) return callback(null, null); var forexMultiplier = this._tradeForexMultiplier(); - if (!forexMultiplier) return callback(new Error('Can\'t compute balance, no tickers yet.')); + if (!forexMultiplier) return callback(new Error('Can\'t compute balance, no tickers yet.')); this.tradeExchange.balance(function (err, localBalance) { if (err) return callback(err); callback(null, localBalance * forexMultiplier); diff --git a/test/api/sendTest.js b/test/api/sendTest.js index 182d7eb2..622e3d15 100644 --- a/test/api/sendTest.js +++ b/test/api/sendTest.js @@ -90,7 +90,7 @@ describe('send test', function() { 'txs': [] }; - var payment_response = { + var payment_response = { 'message': 'Sent 0.1 BTC to 1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64', 'tx_hash': 'f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c', 'notice': 'Some funds are pending confirmation and cannot be spent yet (Value 0.001 BTC)' diff --git a/test/unit/traderFiatBalanceTest.js b/test/unit/traderFiatBalanceTest.js index 12536f26..923e3671 100644 --- a/test/unit/traderFiatBalanceTest.js +++ b/test/unit/traderFiatBalanceTest.js @@ -74,7 +74,7 @@ describe('trader/fiatBalance', function() { assert.equal(fiatBalance, 150 / LOW_BALANCE_MARGIN); }); - it('should calculate balance correctly with transfer and ' + + it('should calculate balance correctly with transfer and ' + 'trade exchange with different currencies', function() { var trader = new Trader(db); trader.configure({