diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/account.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/account.js b/lib/account.js index 931638e0..5a8c3924 100644 --- a/lib/account.js +++ b/lib/account.js @@ -1,16 +1,15 @@ const axios = require("axios"); module.exports = async (asset, user, transaction) => { - const account = await db.Account.findOne( - { - where: { - user_id: user.id, - asset, - pubkey: null - } + const account = await db.Account.findOne({ + where: { + user_id: user.id, + asset, + pubkey: null }, - { transaction } - ); + lock: transaction.LOCK.UPDATE, + transaction + }); if (account) return account; @@ -28,13 +27,16 @@ module.exports = async (asset, user, transaction) => { if (assets[asset]) { ({ domain, ticker, precision, name } = assets[asset]); } else { - const existing = await db.Account.findOne({ - where: { - asset + const existing = await db.Account.findOne( + { + where: { + asset + }, + order: [["id", "ASC"]], + limit: 1 }, - order: [["id", "ASC"]], - limit: 1, - }, { transaction }); + { transaction } + ); if (existing) { ({ domain, ticker, precision, name } = existing); |
