Chore: move tx code into atomic function

This commit is contained in:
csrapr 2021-04-15 14:17:42 +01:00 committed by Josh Harvey
parent 8cd1389de3
commit 4f12bcf4cf
4 changed files with 12 additions and 14 deletions

View file

@ -19,11 +19,7 @@ const MAX_PENDING = 10
module.exports = { post, monitorPending, cancel, PENDING_INTERVAL }
function post (machineTx, pi) {
const TransactionMode = pgp.txMode.TransactionMode
const isolationLevel = pgp.txMode.isolationLevel
const mode = new TransactionMode({ tiLevel: isolationLevel.serializable })
return db.tx({ mode }, cashInAtomic.atomic(machineTx, pi))
return cashInAtomic.atomic(machineTx, pi)
.then(r => {
const updatedTx = r.tx
let blacklisted = false