Sfoglia il codice sorgente

coinex 限频异常拦截,下单冷却1s

JiahengHe 1 anno fa
parent
commit
01cc62547b
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      standard/src/coinex_swap.rs

+ 7 - 1
standard/src/coinex_swap.rs

@@ -1,6 +1,7 @@
 use std::collections::{BTreeMap};
 use std::io::{Error, ErrorKind};
 use std::str::FromStr;
+use std::time::Duration;
 use tokio::sync::mpsc::Sender;
 use async_trait::async_trait;
 use futures::stream::FuturesUnordered;
@@ -454,7 +455,6 @@ impl Platform for CoinexSwap {
             Ok(result)
         } else {
             // error!("take_order error {}", res_data.data);
-            error!("下单数量异常! {:?}", res_data);
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
         }
     }
@@ -625,12 +625,18 @@ impl Platform for CoinexSwap {
                         self_clone.order_sender.send(result).await.unwrap();
                     }
                     Err(error) => {
+                        let error_info = error.to_string();
                         let mut err_order = Order::new();
                         err_order.custom_id = cid.clone();
                         err_order.status = "REMOVE".to_string();
                         // info!("err 数量 {},方向 {},价格 {},c_id {}", amount, side, price, cid);
                         self_clone.order_sender.send(err_order).await.unwrap();
                         self_clone.error_sender.send(error).await.unwrap();
+                        // 触发限频
+                        if error_info.to_string().contains("213:Please don't try too frequently") {
+                            error!("触发限频, 1s后再下单");
+                            tokio::time::sleep(Duration::from_secs(1)).await;
+                        }
                     }
                 }
             });