浏览代码

一次只处理一条通道的消息。

skyfffire 1 年之前
父节点
当前提交
8cb9e34f9a
共有 1 个文件被更改,包括 8 次插入5 次删除
  1. 8 5
      exchanges/tests/binance_swap_test.rs

+ 8 - 5
exchanges/tests/binance_swap_test.rs

@@ -16,7 +16,7 @@ const SECRET_KEY: &str = "";
 
 
 //ws-订阅公共频道信息
-#[tokio::test(flavor = "multi_thread", worker_threads = 8)]
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
 async fn ws_custom_subscribe() {
     global::log_utils::init_log_with_trace();
 
@@ -53,10 +53,13 @@ async fn ws_custom_subscribe() {
                 trace_stack.on_before_unlock_quant();
                 trace_stack.on_after_network(data.time);
 
-                if data.time != 0 {
-                    let delay = trace_stack.before_unlock_quant - trace_stack.after_network;
-                    max_delay = max(max_delay, delay);
-                    info!("{}us, max={}us", delay, max_delay);
+                let delay = trace_stack.before_unlock_quant - trace_stack.after_network;
+                max_delay = max(max_delay, delay);
+                info!("{}us, max={}us", delay, max_delay);
+
+                // 从通道中接收并丢弃所有的消息,直到通道为空
+                while let Ok(Some(_)) = read_rx.try_next() {
+                    // 消息被忽略
                 }
             }
         }