diff --git a/lib/plugins.js b/lib/plugins.js index bb8c1105..67310c0d 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -106,16 +106,20 @@ exports.trade = function trade (deviceId, rawTrade) { // TODO: move this to DB, too // add bill to trader queue (if trader is enabled) const cryptoCode = rawTrade.cryptoCode + const fiatCode = rawTrade.fiatCode + const cryptoAtoms = rawTrade.cryptoAtoms return db.recordBill(deviceId, rawTrade) .then(() => exchange.active(cryptoCode)) .then(active => { if (!active) return - logger.debug('[%s] Pushing trade: %d', cryptoCode, rawTrade.cryptoAtoms) - tradesQueues[cryptoCode].push({ - currency: rawTrade.currency, - cryptoAtoms: rawTrade.cryptoAtoms, + const market = [fiatCode, cryptoCode].join('') + + logger.debug('[%s] Pushing trade: %d', market, cryptoAtoms) + tradesQueues[market].push({ + fiatCode, + cryptoAtoms, cryptoCode, timestamp: Date.now() }) diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index bca24b30..252dac33 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -44,7 +44,7 @@ exports.recordBill = function recordBill (deviceId, rec) { const values = [ rec.uuid, deviceId, - rec.currency, + rec.fiatCode, rec.cryptoCode, rec.toAddress, rec.txId, @@ -83,7 +83,7 @@ exports.addOutgoingTx = function addOutgoingTx (deviceId, tx) { tx.toAddress, tx.cryptoAtoms.toString(), tx.cryptoCode, - tx.currencyCode, + tx.fiatCode, tx.fiat, tx.txHash, null, @@ -111,7 +111,7 @@ exports.addInitialIncoming = function addInitialIncoming (deviceId, tx) { tx.toAddress, tx.cryptoAtoms.toString(), tx.cryptoCode, - tx.currencyCode, + tx.fiatCode, tx.fiat, tx.txHash, tx.phone, @@ -170,7 +170,7 @@ exports.addIncomingPhone = function addIncomingPhone (tx, notified) { function normalizeTx (tx) { tx.toAddress = tx.to_address - tx.currencyCode = tx.currency_code + tx.fiatCode = tx.currency_code tx.txHash = tx.tx_hash tx.cryptoCode = tx.crypto_code tx.cryptoAtoms = new BigNumber(tx.crypto_atoms) diff --git a/lib/routes.js b/lib/routes.js index cc0e31d8..08f013fd 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -84,7 +84,7 @@ function poll (req, res) { const langs = config.languages.machineLanguages const locale = { - currency: config.currencies.fiatCurrency, + fiatCode: config.currencies.fiatCode, localeInfo: { primaryLocale: langs[0], primaryLocales: langs