From fe2127ea31265ba0e755bb558c889975bd8d5b0b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 19 Sep 2018 14:52:36 +1000 Subject: [PATCH] Update SszBlock to use new SSZ API --- lighthouse/state/block/ssz_block.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lighthouse/state/block/ssz_block.rs b/lighthouse/state/block/ssz_block.rs index d9ad3945f..11af7c820 100644 --- a/lighthouse/state/block/ssz_block.rs +++ b/lighthouse/state/block/ssz_block.rs @@ -33,13 +33,14 @@ impl<'a> SszBlock<'a> { pub fn from_vec(vec: &'a Vec) -> Result { + let ssz = &vec[..]; if vec.len() < MIN_SSZ_BLOCK_LENGTH { return Err(BlockValidatorError::SszInvalid); } if vec.len() > MAX_SSZ_BLOCK_LENGTH { return Err(BlockValidatorError::SszInvalid); } - let attestation_len = decode_length(&vec[72..76], LENGTH_BYTES) + let attestation_len = decode_length(ssz, 72, LENGTH_BYTES) .map_err(|_| BlockValidatorError::SszInvalid)?; // Is the length adequate now we know now many attestation // records exist? @@ -47,7 +48,7 @@ impl<'a> SszBlock<'a> { return Err(BlockValidatorError::SszInvalid); } Ok(Self{ - ssz: &vec[..], + ssz, attestation_len }) } @@ -61,7 +62,7 @@ impl<'a> SszBlock<'a> { } pub fn slot_number(&self) -> u64 { - u64::ssz_decode(&self.ssz[32..40]).unwrap() + u64::ssz_decode(&self.ssz, 32).unwrap().0 } pub fn randao_reveal(&self) -> &[u8] {