Commit 4d6bd4e9 by ken

试试看

parent 501d5be8
...@@ -90,12 +90,16 @@ const _subscribe = function(callback, opened_callback = false) { ...@@ -90,12 +90,16 @@ const _subscribe = function(callback, opened_callback = false) {
function subscribe() { function subscribe() {
_subscribe((data) => { _subscribe((data) => {
if (data.channel === accountInfoChannel) { if (data.channel === accountInfoChannel) {
try {
const coins = data.data.coins; const coins = data.data.coins;
const balances = {}; const balances = {};
for (const coin of coins) { for (const coin of coins) {
balances[coin.enName] = {"onOrder": coin.freez, "available": coin.available}; balances[coin.enName] = {"onOrder": coin.freez, "available": coin.available};
} }
redisClient.hset("balance", "zb", JSON.stringify(balances)); redisClient.hset("balance", "zb", JSON.stringify(balances));
} catch (e) {
redisClient.hset("balance", "zb", JSON.stringify({}));
}
} else { } else {
const depth = data; const depth = data;
const key = depth.channel.replace('_', '').toUpperCase() + '@zb'; const key = depth.channel.replace('_', '').toUpperCase() + '@zb';
...@@ -164,7 +168,7 @@ function run() { ...@@ -164,7 +168,7 @@ function run() {
for (const symbol of observerSymbol) { for (const symbol of observerSymbol) {
depthByRest(symbol); depthByRest(symbol);
} }
}, 300); }, 500);
} }
run(); run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment