aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-17 09:17:17 -0800
committerAdam Soltys <[email protected]>2023-01-17 09:17:17 -0800
commit220d6d52b8439a81b572a889d7012f826efc55c5 (patch)
treebfb924033a067459555ae3e7a8e015c4ca59ad00 /lib
parentd7d006b89bcf076d9f8345f5cfd35ef48a658ef2 (diff)
downloadcoinos-server-220d6d52b8439a81b572a889d7012f826efc55c5.tar.gz
coinos-server-220d6d52b8439a81b572a889d7012f826efc55c5.zip
fix rates
Diffstat (limited to 'lib')
-rw-r--r--lib/rates.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/rates.js b/lib/rates.js
index c7d6918c..00e1bd88 100644
--- a/lib/rates.js
+++ b/lib/rates.js
@@ -15,8 +15,6 @@ let connect = () => {
try {
let msg = JSON.parse(event.data);
- if (!store.fx) return;
-
Object.keys(store.fx).map(symbol => {
store.rates[symbol] = msg.c * store.fx[symbol];
});
@@ -39,11 +37,12 @@ export let sendRates = () => broadcast("rate", store.last);
export let getRates = async () => {
connect();
- let date, fx;
+ let date = 0, fx;
let rates = await g("rates");
if (rates) ({ date, fx } = rates);
if (Date.now() - date > 24 * 60 * 60 * 1000) {
+ date = Date.now();
try {
let { rates: fx } = await got(
`https://api.exchangerate.host/latest?base=USD&v={(new Date()).toISOString().split('T')[0]}`