فهرست منبع

event_graph: fix OS sleep breaking dag prune timing; by checking time till next rotation as chuncks of 10secs max

x 20 ساعت پیش
والد
کامیت
a6fbd4607c
1فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 15 1
      src/event_graph/mod.rs

+ 15 - 1
src/event_graph/mod.rs

@@ -2137,6 +2137,20 @@ impl EventGraph {
         loop {
             let next =
                 next_rotation_timestamp(self.config.initial_genesis, self.config.hours_rotation)?;
+
+            loop {
+                match millis_until_next_rotation(next) {
+                    Ok(remaining_ms) => {
+                        if remaining_ms == 0 {
+                            break
+                        }
+                        msleep(remaining_ms.min(10_000)).await;
+                    }
+                    // we've already passed the boundary
+                    Err(_) => break,
+                }
+            }
+
             let hdr = Header {
                 timestamp: next,
                 parents: NULL_PARENTS,
@@ -2144,7 +2158,7 @@ impl EventGraph {
                 content_hash: blake3::hash(&self.config.genesis_contents),
             };
             let genesis = Event { header: hdr, content: self.config.genesis_contents.clone() };
-            msleep(millis_until_next_rotation(next)?).await;
+
             self.dag_prune(genesis).await?;
         }
     }