diff --git a/mev-rs/src/relay.rs b/mev-rs/src/relay.rs index 7bb65238..e4db40d4 100644 --- a/mev-rs/src/relay.rs +++ b/mev-rs/src/relay.rs @@ -13,6 +13,7 @@ use std::{cmp, fmt, hash, ops::Deref}; use tracing::{error, warn}; use url::Url; +#[derive(PartialOrd, Ord, Eq)] pub struct RelayEndpoint { url: Url, public_key: BlsPublicKey, @@ -29,6 +30,12 @@ impl TryFrom for RelayEndpoint { } } +impl cmp::PartialEq for RelayEndpoint { + fn eq(&self, other: &Self) -> bool { + self.public_key == other.public_key + } +} + impl fmt::Debug for RelayEndpoint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.write_str(self.url.as_str()) @@ -57,6 +64,8 @@ pub fn parse_relay_endpoints(relay_urls: &[String]) -> Vec { if relays.is_empty() { error!("no relays could be loaded from the configuration; please fix and restart"); } + relays.sort(); + relays.dedup(); relays }