浏览代码

使用抛弃法测试。

skyfffire 1 年之前
父节点
当前提交
e173d81777
共有 2 个文件被更改,包括 8 次插入37 次删除
  1. 3 37
      exchanges/src/socket_tool.rs
  2. 5 0
      strategy/src/binance_usdt_swap.rs

+ 3 - 37
exchanges/src/socket_tool.rs

@@ -104,43 +104,9 @@ impl AbstractWsMode {
                                     let read = r.lock().await;
 
                                     let mut data_c = data.clone();
-
-                                    let mut is_send = false;
-                                    if data_c.label.contains("gate_usdt_swap") {
-                                        if data_c.channel == "futures.order_book" {
-                                            if read.len() == 0 {
-                                                is_send = true;
-                                            }
-                                        } else {
-                                            is_send = true;
-                                        }
-                                    } else if data_c.label.contains("binance_usdt_swap") {
-                                        if data_c.channel == "bookTicker" {
-                                            if read.len() == 0 {
-                                                is_send = true;
-                                            }
-                                        } else {
-                                            is_send = true;
-                                        }
-                                    } else if data_c.label.contains("bybit_usdt_swap") {
-                                        if data_c.channel == "orderbook" {
-                                            if read.len() == 0 {
-                                                is_send = true;
-                                            }
-                                        } else {
-                                            is_send = true;
-                                        }
-                                    } else {
-                                        if read.len() == 0 {
-                                            is_send = true;
-                                        }
-                                    }
-
-                                    if is_send {
-                                        data_c.label = lable.clone();
-                                        data_c.time = chrono::Utc::now().timestamp_micros();
-                                        read.unbounded_send(data_c).unwrap();
-                                    }
+                                    data_c.label = lable.clone();
+                                    data_c.time = chrono::Utc::now().timestamp_micros();
+                                    read.unbounded_send(data_c).unwrap();
                                 }
 
                                 let code = data.code.clone();

+ 5 - 0
strategy/src/binance_usdt_swap.rs

@@ -44,6 +44,11 @@ pub(crate) async fn reference_binance_swap_run(bool_v1 :Arc<AtomicBool>,
             loop {
                 if let Some(data) = read_rx.next().await {
                     on_data(bot_arc_clone.clone(), &mut update_flag_u, &mut max_buy, &mut min_sell, data).await;
+
+                    // 从通道中接收并丢弃所有的消息,直到通道为空
+                    while let Ok(Some(_)) = read_rx.try_next() {
+                        // 消息被忽略
+                    }
                 }
             }
         });