From: Jeffrey Czyz Date: Thu, 22 Dec 2022 15:04:48 +0000 (-0600) Subject: Drop AsRef<[u8]> implementation for TlvRecord X-Git-Tag: v0.0.114-beta~49^2~10 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=bd0040a02bb7d4884ea4c3b5d731a9fb90c65b84;p=rust-lightning Drop AsRef<[u8]> implementation for TlvRecord Explicitly using TlvRecord::record_bytes makes reading the code more obvious than hiding which bytes are used in AsRef<[u8]>::as_ref. --- diff --git a/lightning/src/offers/merkle.rs b/lightning/src/offers/merkle.rs index 57e7fe683..9031e0eb5 100644 --- a/lightning/src/offers/merkle.rs +++ b/lightning/src/offers/merkle.rs @@ -88,7 +88,7 @@ fn root_hash(data: &[u8]) -> sha256::Hash { let mut leaves = Vec::new(); for record in tlv_stream { if !SIGNATURE_TYPES.contains(&record.r#type) { - leaves.push(tagged_hash_from_engine(leaf_tag.clone(), &record)); + leaves.push(tagged_hash_from_engine(leaf_tag.clone(), &record.record_bytes)); leaves.push(tagged_hash_from_engine(nonce_tag.clone(), &record.type_bytes)); } } @@ -164,10 +164,6 @@ struct TlvRecord<'a> { record_bytes: &'a [u8], } -impl AsRef<[u8]> for TlvRecord<'_> { - fn as_ref(&self) -> &[u8] { &self.record_bytes } -} - impl<'a> Iterator for TlvStream<'a> { type Item = TlvRecord<'a>;