From bd0040a02bb7d4884ea4c3b5d731a9fb90c65b84 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Thu, 22 Dec 2022 09:04:48 -0600 Subject: [PATCH] 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. --- lightning/src/offers/merkle.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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>; -- 2.39.5