Skip to content

Commit

Permalink
Address a review comment concerning Vector::serialized_size.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Jun 18, 2024
1 parent 9881861 commit 6f4a3b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/zcash_encoding/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this library adheres to Rust's notion of
## [Unreleased]
### Added
- `zcash_encoding::CompactSize::serialized_size`
- `zcash_encoding::Vector::serialized_size`
- `zcash_encoding::Vector::serialized_size_of_u8_vec`

## [0.2.0] - 2022-10-19
### Changed
Expand Down
4 changes: 2 additions & 2 deletions components/zcash_encoding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Vector {
}

/// Returns the serialized size of a vector of `u8` as written by `[Vector::write]`.
pub fn serialized_size(vec: &[u8]) -> usize {
pub fn serialized_size_of_u8_vec(vec: &[u8]) -> usize {
let length = vec.len();
CompactSize::serialized_size(length) + length
}
Expand Down Expand Up @@ -341,7 +341,7 @@ mod tests {
let mut data = vec![];
Vector::write(&mut data, &$value, |w, e| w.write_u8(*e)).unwrap();
assert_eq!(&data[..], &$expected[..]);
let serialized_size = Vector::serialized_size(&$value);
let serialized_size = Vector::serialized_size_of_u8_vec(&$value);
assert_eq!(serialized_size, $expected.len());
match Vector::read(&data[..], |r| r.read_u8()) {
Ok(v) => assert_eq!(v, $value),
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl Script {

/// Returns the length of this script as encoded (including the initial CompactSize).
pub fn serialized_size(&self) -> usize {
Vector::serialized_size(&self.0)
Vector::serialized_size_of_u8_vec(&self.0)
}

/// Returns the address that this Script contains, if any.
Expand Down

0 comments on commit 6f4a3b1

Please sign in to comment.