huskies: merge 765

This commit is contained in:
dave
2026-04-28 09:28:13 +00:00
parent 38e828979c
commit 8a51dbd2ed
2 changed files with 9 additions and 3 deletions
+6 -2
View File
@@ -295,9 +295,12 @@ fn write_heartbeat(rendezvous_url: &str, port: u16) {
return;
};
let now = chrono::Utc::now().timestamp() as f64;
let now_ms = chrono::Utc::now().timestamp_millis() as f64;
// Advertise our crdt-sync endpoint.
let address = format!("ws://0.0.0.0:{port}/crdt-sync");
crdt_state::write_node_presence(&node_id, &address, now, true);
// Write millisecond-precision timestamp via LWW register.
crdt_state::write_node_metadata(&node_id, "", None, now_ms);
slog!(
"[agent-mode] Heartbeat written: node={:.12}… rendezvous={rendezvous_url}",
&node_id
@@ -368,8 +371,9 @@ async fn scan_and_claim(
.unwrap_or_default()
.into_iter()
.filter(|n| {
let now = chrono::Utc::now().timestamp() as f64;
n.alive && (now - n.last_seen) < CLAIM_TIMEOUT_SECS
let now_ms = chrono::Utc::now().timestamp_millis() as f64;
let last_ms = n.last_seen_ms.unwrap_or(n.last_seen * 1000.0);
n.alive && (now_ms - last_ms) / 1000.0 < CLAIM_TIMEOUT_SECS
})
.map(|n| n.node_id)
.collect();