Skip to content

Commit

Permalink
implement ord trait
Browse files Browse the repository at this point in the history
  • Loading branch information
somtochiama committed Jul 4, 2024
1 parent 40f53c4 commit ad32c5c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions crates/corro-agent/src/agent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
});
Expand Down
2 changes: 1 addition & 1 deletion crates/corro-types/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ad32c5c

Please sign in to comment.