Simplify parent_hashes code

This commit is contained in:
Paul Hauner 2018-10-21 20:12:17 +11:00
parent 6ee3ad10da
commit 694db90b8c
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -138,12 +138,8 @@ impl<'a> SszBeaconBlock<'a> {
/// The first hash in `ancestor_hashes` is the parent of the block. /// The first hash in `ancestor_hashes` is the parent of the block.
pub fn parent_hash(&self) -> Option<&[u8]> { pub fn parent_hash(&self) -> Option<&[u8]> {
let ancestor_ssz = self.ancestor_hashes(); let ancestor_ssz = self.ancestor_hashes();
let start = LENGTH_BYTES; let start = LENGTH_PREFIX_BYTES;
if ancestor_ssz.len() >= 32 { ancestor_ssz.get(start..start + HASH_SIZE)
Some(&ancestor_ssz[start..start + 32])
} else {
None
}
} }
/// Return the `slot` field. /// Return the `slot` field.