fix postgres locking issue which could lead to rare double send
This commit is contained in:
parent
5cfc2ba491
commit
5b5fc8b810
2 changed files with 10 additions and 5 deletions
|
|
@ -181,7 +181,6 @@ 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;
|
||||
|
|
@ -304,8 +303,6 @@ 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);
|
||||
|
|
@ -350,7 +347,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(silentQuery, client, 'LOCK TABLE transactions'),
|
||||
async.apply(insertOutgoingCompleteTx, client, session, tx),
|
||||
async.apply(removePendingTx, client, session),
|
||||
async.apply(buildOutgoingTx, client, session, tx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue