diff options
| author | Adam Soltys <[email protected]> | 2020-08-05 13:38:16 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-08-05 13:38:16 -0700 |
| commit | 14f944f953dd59106821c9244a89c4eb4a956758 (patch) | |
| tree | 0e824a9d93ea9fb957bab49f3724f6a52ac7102d | |
| parent | fa3c3306ea8c9f1faf0f0c1f7428bd47a48b41d4 (diff) | |
| download | coinos-server-14f944f953dd59106821c9244a89c4eb4a956758.tar.gz coinos-server-14f944f953dd59106821c9244a89c4eb4a956758.zip | |
send single usd rate
| -rw-r--r-- | lib/binance.js | 5 | ||||
| -rw-r--r-- | lib/rates.js | 8 | ||||
| -rw-r--r-- | routes/info.js | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/binance.js b/lib/binance.js index aa6364c8..55b29ee8 100644 --- a/lib/binance.js +++ b/lib/binance.js @@ -7,7 +7,7 @@ module.exports = () => { try { let msg = JSON.parse(event.data); - let fx = app.get("fxrates"); + let fx = app.get("fx"); if (!fx) return; let rates = {}; @@ -16,7 +16,8 @@ module.exports = () => { }); app.set("ask", msg.a); - app.set("last", msg.l); + app.set("bid", msg.b); + app.set("last", msg.c); app.set("balance", await lq.getBalance()); app.set("rates", rates); checkQueue(); diff --git a/lib/rates.js b/lib/rates.js index a8818375..33982ba3 100644 --- a/lib/rates.js +++ b/lib/rates.js @@ -4,7 +4,7 @@ let binance = require("./binance")(); let fetchRates; (fetchRates = async () => { - let rates = require("./devrates"); + let fx = require("./devrates"); if (prod) { try { @@ -12,7 +12,7 @@ let fetchRates; `http://data.fixer.io/api/latest?access_key=${config.fixer}` ); - let fx = res.data.rates; + fx = res.data.rates; fx && Object.keys(fx).map(symbol => { @@ -23,13 +23,13 @@ let fetchRates; } } - app.set("fxrates", rates); + app.set("fx", fx); setTimeout(fetchRates, 7200000); })(); setInterval(() => { - broadcast("rates", app.get("rates")); + broadcast("rate", app.get("last")); }, 1000); setInterval(() => { diff --git a/routes/info.js b/routes/info.js index 4821e82d..5f9e06df 100644 --- a/routes/info.js +++ b/routes/info.js @@ -5,7 +5,7 @@ app.get("/info", ah(async (req, res, next) => { const { clientVersion } = config; const info = { - rates: app.get("rates"), + fx: app.get("fx"), nodes: networks, clientVersion, }; |
