refactor(cb): all callback renamed to cb, and local callbacks to _cb
This commit is contained in:
parent
f15f6d9a0a
commit
f7f98d986e
2 changed files with 22 additions and 22 deletions
|
|
@ -175,7 +175,7 @@ exports.logEvent = function event(rawEvent, deviceFingerprint) {
|
|||
|
||||
|
||||
// Just prompts plugin to send BTC
|
||||
function _sendBitcoins(tx, callback) {
|
||||
function _sendBitcoins(tx, cb) {
|
||||
logger.debug('executing tx: %j', tx);
|
||||
db.changeTxStatus(tx.txId, 'executing');
|
||||
walletPlugin.sendBitcoins(
|
||||
|
|
@ -191,14 +191,14 @@ function _sendBitcoins(tx, callback) {
|
|||
|
||||
// report insufficient funds error
|
||||
db.changeTxStatus(tx.txId, status, {error: err.message});
|
||||
return callback(err);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (txHash) db.changeTxStatus(tx.txId, 'completed', {hash: txHash});
|
||||
else db.changeTxStatus(tx.txId, 'failed', {error: 'No txHash received'});
|
||||
|
||||
pollBalance();
|
||||
callback(null, txHash);
|
||||
cb(null, txHash);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -272,8 +272,8 @@ exports.trade = function trade(rawTrade, deviceFingerprint, cb) {
|
|||
db.recordBill(deviceFingerprint, rawTrade, cb);
|
||||
};
|
||||
|
||||
exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, callback) {
|
||||
executeTx(deviceFingerprint, rawTx.txId, false, callback);
|
||||
exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, cb) {
|
||||
executeTx(deviceFingerprint, rawTx.txId, false, cb);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ function stopTrader() {
|
|||
}
|
||||
|
||||
|
||||
function pollBalance(callback) {
|
||||
function pollBalance(cb) {
|
||||
logger.debug('collecting balance');
|
||||
|
||||
var jobs = {
|
||||
|
|
@ -360,31 +360,31 @@ function pollBalance(callback) {
|
|||
async.parallel(jobs, function(err, balance) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
return callback && callback(err);
|
||||
return cb && cb(err);
|
||||
}
|
||||
|
||||
logger.debug('Balance update:', balance);
|
||||
balance.timestamp = Date.now();
|
||||
lastBalances = balance;
|
||||
|
||||
return callback && callback(null, lastBalances);
|
||||
return cb && cb(null, lastBalances);
|
||||
});
|
||||
}
|
||||
|
||||
function pollRate(callback) {
|
||||
function pollRate(cb) {
|
||||
logger.debug('polling for rates (%s)', tickerPlugin.NAME);
|
||||
|
||||
tickerPlugin.ticker(deviceCurrency, function(err, resRates) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
return callback && callback(err);
|
||||
return cb && cb(err);
|
||||
}
|
||||
|
||||
logger.debug('got rates: %j', resRates);
|
||||
resRates.timestamp = new Date();
|
||||
lastRates = resRates;
|
||||
|
||||
return callback && callback(null, lastRates);
|
||||
return cb && cb(null, lastRates);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -422,11 +422,11 @@ function clearSession(deviceFingerprint) {
|
|||
/*
|
||||
* Trader functions
|
||||
*/
|
||||
function purchase(trade, callback) {
|
||||
function purchase(trade, cb) {
|
||||
traderPlugin.purchase(trade.satoshis, null, function(err) {
|
||||
if (err) return callback(err);
|
||||
if (err) return cb(err);
|
||||
pollBalance();
|
||||
if (typeof callback === 'function') callback();
|
||||
if (typeof cb === 'function') cb();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -470,10 +470,10 @@ function executeTrades() {
|
|||
/*
|
||||
* ID Verifier functions
|
||||
*/
|
||||
exports.verifyUser = function verifyUser(data, callback) {
|
||||
idVerifierPlugin.verifyUser(data, callback);
|
||||
exports.verifyUser = function verifyUser(data, cb) {
|
||||
idVerifierPlugin.verifyUser(data, cb);
|
||||
};
|
||||
|
||||
exports.verifyTx = function verifyTx(data, callback) {
|
||||
idVerifierPlugin.verifyTransaction(data, callback);
|
||||
exports.verifyTx = function verifyTx(data, cb) {
|
||||
idVerifierPlugin.verifyTransaction(data, cb);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue