diff --git a/node-data/src/ledger/faults.rs b/node-data/src/ledger/faults.rs index f9948d39f..4d0faa65d 100644 --- a/node-data/src/ledger/faults.rs +++ b/node-data/src/ledger/faults.rs @@ -81,8 +81,14 @@ impl From for InvalidFault { } impl Fault { - /// Hash the serialized form - pub fn hash(&self) -> [u8; 32] { + // TODO: change to HEIGHT|TYPE|PROV_KEY once faults collection is + // implemented + pub fn id(&self) -> [u8; 32] { + self.digest() + } + + /// 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() diff --git a/node-data/src/ledger/transaction.rs b/node-data/src/ledger/transaction.rs index e4d13aa49..c7b4901a7 100644 --- a/node-data/src/ledger/transaction.rs +++ b/node-data/src/ledger/transaction.rs @@ -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() }