From f01be72d8fb152caf5a2484ccc2c2d4af3280f13 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 10 Jul 2025 12:15:37 -0300 Subject: [PATCH] move impl of hash to existing impl Transaction block --- common/src/transaction.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common/src/transaction.rs b/common/src/transaction.rs index 0c43521..a02b692 100644 --- a/common/src/transaction.rs +++ b/common/src/transaction.rs @@ -57,16 +57,6 @@ pub struct Transaction { pub state_changes: (serde_json::Value, usize), } -impl Transaction { - pub fn hash(&self) -> TreeHashType { - let raw_data = serde_json::to_vec(&self).unwrap(); - let mut hasher = sha2::Sha256::new(); - hasher.update(&raw_data); - TreeHashType::from(hasher.finalize_fixed()) - } -} - - #[derive(Debug, Serialize, Deserialize)] pub struct MintMoneyPublicTx { pub acc: [u8; 32], @@ -161,6 +151,13 @@ impl ActionData { } impl Transaction { + pub fn hash(&self) -> TreeHashType { + let raw_data = serde_json::to_vec(&self).unwrap(); + let mut hasher = sha2::Sha256::new(); + hasher.update(&raw_data); + TreeHashType::from(hasher.finalize_fixed()) + } + pub fn log(&self) { info!("Transaction hash is {:?}", hex::encode(self.hash())); info!("Transaction tx_kind is {:?}", self.tx_kind);