Re-add canonical_root methods to block & state

Turns out they were pretty useful
This commit is contained in:
Paul Hauner 2019-03-07 12:25:00 +11:00
parent dad140a338
commit e448882102
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 10 additions and 0 deletions

View File

@ -44,6 +44,11 @@ impl BeaconBlock {
},
}
}
/// Returns the `hash_tree_root` of the block.
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.hash_tree_root()[..])
}
}
#[cfg(test)]

View File

@ -233,6 +233,11 @@ impl BeaconState {
Ok(genesis_state)
}
/// Returns the `hash_tree_root` of the state.
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.hash_tree_root()[..])
}
/// Build an epoch cache, unless it is has already been built.
pub fn build_epoch_cache(
&mut self,