add hash of the node method

This commit is contained in:
NikVolf 2019-11-28 10:31:16 +03:00
parent 71c6188bf8
commit 26be46573e
1 changed files with 8 additions and 0 deletions

View File

@ -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)]