diff --git a/beacon_chain/utils/ssz/src/decode.rs b/beacon_chain/utils/ssz/src/decode.rs index bb51610ee..3d81b70ba 100644 --- a/beacon_chain/utils/ssz/src/decode.rs +++ b/beacon_chain/utils/ssz/src/decode.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))] + use super::{ LENGTH_BYTES, }; @@ -79,7 +81,7 @@ pub fn decode_length(bytes: &[u8], index: usize, length_bytes: usize) let mut len: usize = 0; for i in index..index+length_bytes { let offset = (index+length_bytes - i - 1) * 8; - len = ((bytes[i] as usize) << offset) | len; + len |= (bytes[i] as usize) << offset; }; Ok(len) } diff --git a/beacon_chain/utils/ssz/src/encode.rs b/beacon_chain/utils/ssz/src/encode.rs index 0a5ac4b4d..91753bacf 100644 --- a/beacon_chain/utils/ssz/src/encode.rs +++ b/beacon_chain/utils/ssz/src/encode.rs @@ -1,15 +1,9 @@ #![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))] use super::{ - LENGTH_BYTES, - MAX_LIST_SIZE, + LENGTH_BYTES }; -#[derive(Debug)] -pub enum EncodeError { - ListTooLong, -} - pub trait Encodable { fn ssz_append(&self, s: &mut SszStream); } diff --git a/beacon_chain/utils/ssz/src/impl_decode.rs b/beacon_chain/utils/ssz/src/impl_decode.rs index a6b8843bd..d0b5d2d67 100644 --- a/beacon_chain/utils/ssz/src/impl_decode.rs +++ b/beacon_chain/utils/ssz/src/impl_decode.rs @@ -53,11 +53,10 @@ impl Decodable for H256 { -> Result<(Self, usize), DecodeError> { if bytes.len() < 32 || bytes.len() - 32 < index { - return Err(DecodeError::TooShort) + Err(DecodeError::TooShort) } else { - return Ok((H256::from(&bytes[index..(index + 32)]), - index + 32)); + Ok((H256::from(&bytes[index..(index + 32)]), index + 32)) } } }