Bugfix in event orering (BTreeSet would only keep one event with the same created_at)

This commit is contained in:
Mike Dilger 2024-04-25 10:45:02 +12:00
parent 9b0f293230
commit 38a20d0a78
2 changed files with 4 additions and 2 deletions

View File

@ -205,7 +205,9 @@ impl PartialOrd for Event<'_> {
impl Ord for Event<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.created_at().cmp(&other.created_at())
self.created_at()
.cmp(&other.created_at())
.then(self.id().cmp(&other.id()))
}
}

View File

@ -2,7 +2,7 @@ use crate::error::Error;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Id(pub [u8; 32]);
impl Id {