From d01159ce9eee956dca32fd69525c0edd5aae9477 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 15 Jan 2021 15:31:46 -0800 Subject: add more transactions and locks --- routes/bitcoin/receive.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'routes/bitcoin/receive.js') diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js index e0e3828b..2a6a7954 100644 --- a/routes/bitcoin/receive.js +++ b/routes/bitcoin/receive.js @@ -159,10 +159,13 @@ setInterval(async () => { let total = p.amount + p.tip; p.confirmed = 1; - p.account.balance += total; - p.account.pending -= Math.min(p.account.pending, total); - await p.account.save({ transaction }); + await p.account.increment({ balance: total }, { transaction }); + await p.account.decrement( + { pending: Math.min(p.account.pending, total) }, + { transaction } + ); + await p.account.reload({ transaction }); await p.save({ transaction }); p = p.get({ plain: true }); -- cgit v1.2.3