From: Matt Corallo Date: Mon, 13 Nov 2023 22:48:48 +0000 (+0000) Subject: Rely on const generic big arrays for `PartialEq` in msgs X-Git-Tag: v0.0.119~54^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=eb23c1e43b0372e53c0b19b1eeafebeef50d2089;p=rust-lightning Rely on const generic big arrays for `PartialEq` in msgs Implementation of standard traits on arrays longer than 32 elements was shipped in rustc 1.47, which is below our MSRV of 1.48 and we can use to remove some unnecessary manual implementation of `PartialEq` on `OnionPacket`. --- diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index d43ad6d0a..47a98f734 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1675,7 +1675,7 @@ pub use self::fuzzy_internal_msgs::*; pub(crate) use self::fuzzy_internal_msgs::*; /// BOLT 4 onion packet including hop data for the next peer. -#[derive(Clone)] +#[derive(Clone, PartialEq, Eq)] pub struct OnionPacket { /// BOLT 4 version number. pub version: u8, @@ -1703,18 +1703,6 @@ impl onion_utils::Packet for OnionPacket { } } -impl Eq for OnionPacket { } -impl PartialEq for OnionPacket { - fn eq(&self, other: &OnionPacket) -> bool { - for (i, j) in self.hop_data.iter().zip(other.hop_data.iter()) { - if i != j { return false; } - } - self.version == other.version && - self.public_key == other.public_key && - self.hmac == other.hmac - } -} - impl fmt::Debug for OnionPacket { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_fmt(format_args!("OnionPacket version {} with hmac {:?}", self.version, &self.hmac[..]))