From 694db90b8cdb166eff7bf26b756487c48f4d1ed7 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 21 Oct 2018 20:12:17 +1100 Subject: [PATCH] Simplify parent_hashes code --- beacon_chain/utils/ssz_helpers/src/ssz_beacon_block.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/beacon_chain/utils/ssz_helpers/src/ssz_beacon_block.rs b/beacon_chain/utils/ssz_helpers/src/ssz_beacon_block.rs index d244fbb19..3066f5679 100644 --- a/beacon_chain/utils/ssz_helpers/src/ssz_beacon_block.rs +++ b/beacon_chain/utils/ssz_helpers/src/ssz_beacon_block.rs @@ -138,12 +138,8 @@ impl<'a> SszBeaconBlock<'a> { /// The first hash in `ancestor_hashes` is the parent of the block. pub fn parent_hash(&self) -> Option<&[u8]> { let ancestor_ssz = self.ancestor_hashes(); - let start = LENGTH_BYTES; - if ancestor_ssz.len() >= 32 { - Some(&ancestor_ssz[start..start + 32]) - } else { - None - } + let start = LENGTH_PREFIX_BYTES; + ancestor_ssz.get(start..start + HASH_SIZE) } /// Return the `slot` field.