Skip to content

Commit

Permalink
Remove PartialOrd implementation from Certificate
Browse files Browse the repository at this point in the history
As it's no longer used and would need a complicated implementation
to work with mutiple beacon types.
  • Loading branch information
Alenar committed Mar 27, 2024
1 parent 58f41ae commit bdb3065
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions mithril-common/src/entities/certificate.rs
Expand Up @@ -4,7 +4,6 @@ use crate::crypto_helper::{
use crate::entities::{
CardanoDbBeacon, CertificateMetadata, Epoch, ProtocolMessage, SignedEntityType,
};
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};

use crate::era_deprecate;
Expand Down Expand Up @@ -149,27 +148,12 @@ impl Certificate {
}
}

//bbb// todo: review both PartialEq & PartialOrd implementations, they should not relies on the
// epoch but maybe the initiated at and/or sealed at metadata ?
impl PartialEq for Certificate {
fn eq(&self, other: &Self) -> bool {
self.epoch.eq(&other.epoch) && self.hash.eq(&other.hash)
}
}

impl PartialOrd for Certificate {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
// Order by epoch first then per hash
match self.epoch.partial_cmp(&other.epoch) {
Some(Ordering::Equal) => self.hash.partial_cmp(&other.hash),
Some(other) => Some(other),
// Beacons may be not comparable (most likely because the network isn't the same) in
// that case we can still order per hash
None => self.hash.partial_cmp(&other.hash),
}
}
}

impl Debug for Certificate {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let should_be_exhaustive = f.alternate();
Expand Down

0 comments on commit bdb3065

Please sign in to comment.