aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-06-16 13:53:11 -0700
committerAdam Soltys <[email protected]>2025-06-16 13:53:14 -0700
commit26d7394c12611193b39da1b7d1d7aec8dc7dec09 (patch)
tree686c95d4cb755530331c89efe58348862a08460c
parent34774759b233c1535c74a7f2783ffd40a542ab9d (diff)
downloadcoinos-server-26d7394c12611193b39da1b7d1d7aec8dc7dec09.tar.gz
coinos-server-26d7394c12611193b39da1b7d1d7aec8dc7dec09.zip
fix rates polling
-rw-r--r--lib/rates.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/rates.ts b/lib/rates.ts
index d9ae7f8d..dcb44464 100644
--- a/lib/rates.ts
+++ b/lib/rates.ts
@@ -12,7 +12,7 @@ const connect = async () => {
if (ws && ws.readyState === 1 && Date.now() - last < 5000) return;
if (ws) ws.terminate() && (await sleep(Math.round(Math.random() * 1000)));
- ws = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@ticker");
+ ws = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@miniTicker");
ws.onmessage = async (event) => {
try {
@@ -25,9 +25,13 @@ const connect = async () => {
rates[symbol] = msg.c * fx[symbol];
});
- rates.IRT = (
- (await got("https://api.nobitex.ir/v2/orderbook/BTCIRT").json()) as any
- ).lastTradePrice;
+ try {
+ rates.IRT = (
+ (await got(
+ "https://api.nobitex.ir/v2/orderbook/BTCIRT",
+ ).json()) as any
+ ).lastTradePrice;
+ } catch (e) {}
rate = msg.c;
s("rate", rate);