瀏覽代碼

设置等待时间,防止执行过快

JiahengHe 8 月之前
父節點
當前提交
5bda2614a1
共有 1 個文件被更改,包括 8 次插入5 次删除
  1. 8 5
      src/core_libs.rs

+ 8 - 5
src/core_libs.rs

@@ -144,14 +144,17 @@ pub async fn init(params: Params,
             // 计算需要等待的时间
             let wait_duration = next_hour - now;
             let wait_secs = wait_duration.num_seconds() as u64;
-
-
-            // 等待到下一个整点
-            sleep_until(Instant::now() + std::time::Duration::from_secs(wait_secs)).await;
-
+            
+            if wait_secs > 0 {
+                sleep_until(Instant::now() + Duration::from_secs(wait_secs)).await;
+            }
+            
             // 更新近7天的交易量统计
             let mut core = trade_volume_core_arc.lock().await;
             core.update_trade_volume().await;
+
+            // 等待一分钟以避免过快地循环
+            sleep_until(Instant::now() + Duration::from_secs(60)).await;
         }
     });