Skip to content

Commit

Permalink
node-data: rename hash to digest
Browse files Browse the repository at this point in the history
- Update comments
  • Loading branch information
Neotamandua committed Dec 5, 2024
1 parent 2560a5d commit 220488c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions node-data/src/ledger/faults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl From<BlsSigError> for InvalidFault {
}

impl Fault {
/// Hash the serialized form
pub fn hash(&self) -> [u8; 32] {
/// Digest the serialized form
pub fn digest(&self) -> [u8; 32] {
let mut b = vec![];
self.write(&mut b).expect("Write to a vec shall not fail");
sha3::Sha3_256::digest(&b[..]).into()
Expand Down
8 changes: 5 additions & 3 deletions node-data/src/ledger/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ pub struct SpentTransaction {
}

impl Transaction {
/// Computes the hash of the transaction.
/// Computes the hash digest of the entire transaction data.
///
/// This method returns the hash of the entire
/// This method returns the Sha3 256 digest of the entire
/// transaction in its serialized form
///
/// The digest hash is currently only being used in the merkle tree.
///
/// ### Returns
/// An array of 32 bytes representing the hash of the transaction.
pub fn hash(&self) -> [u8; 32] {
pub fn digest(&self) -> [u8; 32] {
sha3::Sha3_256::digest(self.inner.to_var_bytes()).into()
}

Expand Down

0 comments on commit 220488c

Please sign in to comment.