diff --git a/crates/corro-agent/src/agent/handlers.rs b/crates/corro-agent/src/agent/handlers.rs index 6b60d490..6a7e079d 100644 --- a/crates/corro-agent/src/agent/handlers.rs +++ b/crates/corro-agent/src/agent/handlers.rs @@ -6,7 +6,6 @@ use std::collections::BTreeMap; use std::collections::HashMap; use std::ops::RangeInclusive; -use std::cmp::Ordering; use std::{ cmp, collections::VecDeque, @@ -825,15 +824,7 @@ pub async fn handle_sync( .need_len_for_actor(&b.0) .cmp(&sync_state.need_len_for_actor(&a.0)) // if equal, look at last sync time - .then_with(|| { - if a.3.is_none() { - return Ordering::Greater; - } - if b.3.is_none() { - return Ordering::Less; - } - a.3.unwrap().cmp(&b.3.unwrap()) - }) + .then_with(|| a.3.cmp(&b.3)) // if equal, look at proximity (via `ring`) .then_with(|| a.1.cmp(&b.1)) }); diff --git a/crates/corro-types/src/broadcast.rs b/crates/corro-types/src/broadcast.rs index ee859ad1..382bfce5 100644 --- a/crates/corro-types/src/broadcast.rs +++ b/crates/corro-types/src/broadcast.rs @@ -264,7 +264,7 @@ pub enum TimestampParseError { Parse(ParseNTP64Error), } -#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Hash)] +#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Ord, Hash)] #[serde(transparent)] pub struct Timestamp(pub NTP64);