use core::cmp::Ordering;
use bee_block::payload::milestone::MilestoneIndex;
use serde::{Deserialize, Serialize};
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct MilestoneKeyRange {
#[serde(alias = "publicKey")]
public_key: String,
start: MilestoneIndex,
end: MilestoneIndex,
}
impl MilestoneKeyRange {
pub fn new(public_key: String, start: MilestoneIndex, end: MilestoneIndex) -> Self {
Self { public_key, start, end }
}
pub fn public_key(&self) -> &String {
&self.public_key
}
pub fn start(&self) -> MilestoneIndex {
self.start
}
pub fn end(&self) -> MilestoneIndex {
self.end
}
}
impl Ord for MilestoneKeyRange {
fn cmp(&self, other: &Self) -> Ordering {
self.start.cmp(&other.start)
}
}
impl PartialOrd for MilestoneKeyRange {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}