Ver Fonte

过滤数据

hl há 1 ano atrás
pai
commit
cd852d291b
1 ficheiros alterados com 17 adições e 14 exclusões
  1. 17 14
      exchanges/src/cointr_swap_ws.rs

+ 17 - 14
exchanges/src/cointr_swap_ws.rs

@@ -347,12 +347,12 @@ impl CointrSwapWs {
             Some(_) => {
                 let msg = json_value["msg"].as_str().unwrap();
                 match msg {
-                    "connect.success" =>{
+                    "connect.success" => {
                         res_data.code = -201;
                         res_data.message = format!("连接成功:");
                         return res_data;
                     }
-                    "subscribe.faild" =>{
+                    "subscribe.faild" => {
                         res_data.code = 400;
                         res_data.message = format!("订阅失败:{}", msg);
                         return res_data;
@@ -386,19 +386,22 @@ impl CointrSwapWs {
         match channel {
             None => {}
             Some(c) => {
-                res_data.code = 200;
-                res_data.data = json_value.clone();
-                if c.contains("books_perp") {
-                    res_data.channel = "futures.order_book".to_string();
-                } else if c.contains("trades_perp") {
-                    res_data.channel = "futures.trades".to_string();
-                } else if c.contains("kline_perp") {
-                    res_data.channel = "futures.candlesticks".to_string();
-                } else {
-                    res_data.code = 400;
-                    res_data.channel = "未知推送数据".to_string();
+                let action = json_value["action"].as_str().unwrap();
+                if action.contains("update") {
+                    res_data.code = 200;
+                    res_data.data = json_value.clone();
+                    if c.contains("books_perp") {
+                        res_data.channel = "futures.order_book".to_string();
+                    } else if c.contains("trades_perp") {
+                        res_data.channel = "futures.trades".to_string();
+                    } else if c.contains("kline_perp") {
+                        res_data.channel = "futures.candlesticks".to_string();
+                    } else {
+                        res_data.code = 400;
+                        res_data.channel = "未知推送数据".to_string();
+                    }
+                    return res_data;
                 }
-                return res_data;
             }
         }