JSHint trader

This commit is contained in:
Maciej Małecki 2014-04-16 14:58:44 +02:00
parent 971f3f2f54
commit 8cb9783bde

View file

@ -24,7 +24,10 @@ Trader.prototype._findExchange = function (name) {
try { try {
exchange = require('lamassu-' + name); exchange = require('lamassu-' + name);
} catch (err) { } catch (err) {
if (!err.message.match(/Cannot find module/)) throw err; if (!err.message.match(/Cannot find module/)) {
throw err;
}
exchange = require(path.join(path.dirname(__dirname), 'exchanges', name)); exchange = require(path.join(path.dirname(__dirname), 'exchanges', name));
} }
@ -85,7 +88,9 @@ Trader.prototype.fiatBalance = function (transferSatoshis, tradeFiat) {
var balance = this.balance; var balance = this.balance;
var commission = this.config.exchanges.settings.commission; var commission = this.config.exchanges.settings.commission;
if (!rate || !balance) return 0; if (!rate || !balance) {
return 0;
}
// The rate is actually our commission times real rate. // The rate is actually our commission times real rate.
rate = commission * rate; rate = commission * rate;
@ -116,7 +121,9 @@ Trader.prototype.sendBitcoins = function (deviceFingerprint, tx, cb) {
var self = this; var self = this;
self.db.summonTransaction(deviceFingerprint, tx, function (err, isNew, txHash) { self.db.summonTransaction(deviceFingerprint, tx, function (err, isNew, txHash) {
if (err) return cb(err); if (err) {
return cb(err);
}
if (isNew) { if (isNew) {
return self.transferExchange.sendBitcoins( return self.transferExchange.sendBitcoins(
@ -178,7 +185,7 @@ Trader.prototype.pollBalance = function (callback) {
self.logger.info('Balance update:', balance); self.logger.info('Balance update:', balance);
self.balance = balance; self.balance = balance;
callback && callback(null, balance); return callback && callback(null, balance);
}); });
}; };
@ -194,7 +201,7 @@ Trader.prototype.pollRate = function (callback) {
self.logger.info('Rate update:', rate); self.logger.info('Rate update:', rate);
self.rates[currency] = {rate: rate, timestamp: new Date()}; self.rates[currency] = {rate: rate, timestamp: new Date()};
callback && callback(null, self.rates[currency]); return callback && callback(null, self.rates[currency]);
}); });
}; };