Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Daira Emma Hopwood <[email protected]>
  • Loading branch information
nuttycom and daira committed Oct 24, 2023
1 parent f7527e1 commit 9cd60c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zcash_primitives/src/transaction/components/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,17 @@ impl NonNegativeAmount {
Self::from_u64(amount)
}

/// Reads a NonNegativeAmount from a signed 64-bit little-endian integer.
/// Reads a NonNegativeAmount from a signed integer represented as a two's
/// complement 64-bit little-endian value.
///
/// Returns an error if the amount is outside the range `{0..MAX_MONEY}`.
pub fn from_nonnegative_i64_le_bytes(bytes: [u8; 8]) -> Result<Self, ()> {
let amount = i64::from_le_bytes(bytes);
Self::from_nonnegative_i64(amount)
}

/// Returns this NonNegativeAmount encoded as a signed 64-bit little-endian integer.
/// Returns this NonNegativeAmount encoded as a signed two's complement 64-bit
/// little-endian value.
pub fn to_i64_le_bytes(self) -> [u8; 8] {
self.0.to_i64_le_bytes()
}
Expand Down

0 comments on commit 9cd60c5

Please sign in to comment.