huskies: merge 765
This commit is contained in:
@@ -295,9 +295,12 @@ fn write_heartbeat(rendezvous_url: &str, port: u16) {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let now = chrono::Utc::now().timestamp() as f64;
|
let now = chrono::Utc::now().timestamp() as f64;
|
||||||
|
let now_ms = chrono::Utc::now().timestamp_millis() as f64;
|
||||||
// Advertise our crdt-sync endpoint.
|
// Advertise our crdt-sync endpoint.
|
||||||
let address = format!("ws://0.0.0.0:{port}/crdt-sync");
|
let address = format!("ws://0.0.0.0:{port}/crdt-sync");
|
||||||
crdt_state::write_node_presence(&node_id, &address, now, true);
|
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!(
|
slog!(
|
||||||
"[agent-mode] Heartbeat written: node={:.12}… rendezvous={rendezvous_url}",
|
"[agent-mode] Heartbeat written: node={:.12}… rendezvous={rendezvous_url}",
|
||||||
&node_id
|
&node_id
|
||||||
@@ -368,8 +371,9 @@ async fn scan_and_claim(
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|n| {
|
.filter(|n| {
|
||||||
let now = chrono::Utc::now().timestamp() as f64;
|
let now_ms = chrono::Utc::now().timestamp_millis() as f64;
|
||||||
n.alive && (now - n.last_seen) < CLAIM_TIMEOUT_SECS
|
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)
|
.map(|n| n.node_id)
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
+3
-1
@@ -70,10 +70,12 @@ impl MeshManager {
|
|||||||
let alive_peers: Vec<(String, String)> = nodes
|
let alive_peers: Vec<(String, String)> = nodes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|n| {
|
.filter(|n| {
|
||||||
|
let now_ms = now * 1000.0;
|
||||||
|
let last_ms = n.last_seen_ms.unwrap_or(n.last_seen * 1000.0);
|
||||||
n.alive
|
n.alive
|
||||||
&& !n.address.is_empty()
|
&& !n.address.is_empty()
|
||||||
&& n.node_id != self.our_node_id
|
&& n.node_id != self.our_node_id
|
||||||
&& (now - n.last_seen) < 600.0
|
&& (now_ms - last_ms) / 1000.0 < 600.0
|
||||||
&& !self.is_rendezvous_peer(&n.address)
|
&& !self.is_rendezvous_peer(&n.address)
|
||||||
})
|
})
|
||||||
.map(|n| (n.node_id, n.address))
|
.map(|n| (n.node_id, n.address))
|
||||||
|
|||||||
Reference in New Issue
Block a user