try locking txs table
This commit is contained in:
parent
71e5ec64f5
commit
5cfc2ba491
4 changed files with 61 additions and 3 deletions
|
|
@ -121,7 +121,7 @@ function loadOrConfigPlugin(pluginHandle, pluginType, currency,
|
|||
pluginHandle = loadPlugin(currentName, pluginConfig);
|
||||
currentlyUsedPlugins[pluginType] = currentName
|
||||
logger.debug('plugin(%s) loaded: %s', pluginType, pluginHandle.NAME ||
|
||||
currentName);
|
||||
currentName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -311,6 +311,8 @@ exports.trade = function trade(session, rawTrade, cb) {
|
|||
currencyCode: rawTrade.currency
|
||||
};
|
||||
|
||||
console.log('****************** DEBUG2 *****************')
|
||||
console.log(db.addOutgoingPending)
|
||||
async.parallel([
|
||||
async.apply(db.addOutgoingPending, session, tx.currencyCode, tx.toAddress),
|
||||
async.apply(db.recordBill, session, rawTrade)
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ function billsAndTxs(client, session, cb) {
|
|||
}
|
||||
|
||||
function computeSendAmount(tx, totals) {
|
||||
console.log('DEBUG10')
|
||||
var fiatRemaining = (tx.fiat || totals.billsFiat) - totals.txFiat;
|
||||
var satoshisRemaining = (tx.satoshis || totals.billsSatoshis) -
|
||||
totals.txSatoshis;
|
||||
|
|
@ -303,6 +304,8 @@ function insertTx(client, session, incoming, tx, satoshis, fiat, stage,
|
|||
tx.error
|
||||
];
|
||||
|
||||
console.log('DEBUG11')
|
||||
|
||||
query(client, getInsertQuery('transactions', fields, true), values,
|
||||
function(err, results) {
|
||||
if (err) return cb(err);
|
||||
|
|
@ -347,6 +350,7 @@ exports.addOutgoingTx = function addOutgoingTx(session, tx, cb) {
|
|||
if (cerr) return cb(cerr);
|
||||
async.series([
|
||||
async.apply(silentQuery, client, 'BEGIN'),
|
||||
async.apply(silentQuery, client, 'LOCK TABLE transactions NOWAIT'),
|
||||
async.apply(insertOutgoingCompleteTx, client, session, tx),
|
||||
async.apply(removePendingTx, client, session),
|
||||
async.apply(buildOutgoingTx, client, session, tx)
|
||||
|
|
@ -357,7 +361,7 @@ exports.addOutgoingTx = function addOutgoingTx(session, tx, cb) {
|
|||
}
|
||||
silentQuery(client, 'COMMIT', [], function() {
|
||||
done();
|
||||
var toSend = results[3];
|
||||
var toSend = results[4];
|
||||
cb(null, toSend);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue