]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop AsRef<[u8]> implementation for TlvRecord
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 22 Dec 2022 15:04:48 +0000 (09:04 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 18 Jan 2023 21:31:48 +0000 (15:31 -0600)
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

index 57e7fe6833c2fd7eac8f4ec6125a0e0b2bc58039..9031e0eb540f0c358a21f3480f503486ca21fba1 100644 (file)
@@ -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>;