From 26be46573ee7e0094f19d861fd29793adda6298e Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 28 Nov 2019 10:31:16 +0300 Subject: [PATCH] add hash of the node method --- src/node_data.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/node_data.rs b/src/node_data.rs index ac545e2..0e972f9 100644 --- a/src/node_data.rs +++ b/src/node_data.rs @@ -193,6 +193,14 @@ impl NodeData { let mut cursor = std::io::Cursor::new(buf); Self::read(consensus_branch_id, &mut cursor) } + + pub fn hash(&self) -> [u8; 32] { + let mut buf = [0u8; 32]; + + let bytes = self.to_bytes(); + + blake2b_personal(&personalization(self.consensus_branch_id), &bytes) + } } #[cfg(test)]