Use Witness::len instead of accessing field

In preparation for moving the `Witness` oven to `primitives` use the
`len` function instead of accessing the `witness_elements` field.

No logic change, `Witness::len()` returns `witness_elements`.
This commit is contained in:
Tobin C. Harding 2024-09-24 10:20:04 +10:00
parent 12e4671810
commit be163eec99
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 1 additions and 1 deletions

View File

@ -231,7 +231,7 @@ impl Encodable for Witness {
// `self.content` includes the varints so encoding here includes them, as expected.
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
let content_with_indices_len = self.content.len();
let indices_size = self.witness_elements * 4;
let indices_size = self.len() * 4;
let content_len = content_with_indices_len - indices_size;
Ok(w.emit_compact_size(self.witness_elements)? + w.emit_slice(&self.content[..content_len])?)
}