From bf6fe175dd692ccf4870cefc8184254c8925b723 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 26 May 2021 15:08:08 +1000 Subject: [PATCH] Stop deriving PartialEq for MetaAddr This makes sure Ord and ParitalEq are always consistent. --- zebra-network/src/meta_addr.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zebra-network/src/meta_addr.rs b/zebra-network/src/meta_addr.rs index e89c28cc..42566240 100644 --- a/zebra-network/src/meta_addr.rs +++ b/zebra-network/src/meta_addr.rs @@ -106,7 +106,7 @@ impl PartialOrd for PeerAddrState { /// An address with metadata on its advertised services and last-seen time. /// /// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#Network_address) -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug)] pub struct MetaAddr { /// The peer's address. pub addr: SocketAddr, @@ -319,6 +319,14 @@ impl PartialOrd for MetaAddr { } } +impl PartialEq for MetaAddr { + fn eq(&self, other: &Self) -> bool { + self.cmp(other) == Ordering::Equal + } +} + +impl Eq for MetaAddr {} + impl ZcashSerialize for MetaAddr { fn zcash_serialize(&self, mut writer: W) -> Result<(), std::io::Error> { writer.write_u32::(