a few more quick changes and another range loop ignore
This commit is contained in:
parent
869049d099
commit
d3ec313b43
@ -1,3 +1,5 @@
|
|||||||
|
#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))]
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
LENGTH_BYTES,
|
LENGTH_BYTES,
|
||||||
};
|
};
|
||||||
@ -79,7 +81,7 @@ pub fn decode_length(bytes: &[u8], index: usize, length_bytes: usize)
|
|||||||
let mut len: usize = 0;
|
let mut len: usize = 0;
|
||||||
for i in index..index+length_bytes {
|
for i in index..index+length_bytes {
|
||||||
let offset = (index+length_bytes - i - 1) * 8;
|
let offset = (index+length_bytes - i - 1) * 8;
|
||||||
len = ((bytes[i] as usize) << offset) | len;
|
len |= (bytes[i] as usize) << offset;
|
||||||
};
|
};
|
||||||
Ok(len)
|
Ok(len)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))]
|
#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))]
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
LENGTH_BYTES,
|
LENGTH_BYTES
|
||||||
MAX_LIST_SIZE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum EncodeError {
|
|
||||||
ListTooLong,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Encodable {
|
pub trait Encodable {
|
||||||
fn ssz_append(&self, s: &mut SszStream);
|
fn ssz_append(&self, s: &mut SszStream);
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,10 @@ impl Decodable for H256 {
|
|||||||
-> Result<(Self, usize), DecodeError>
|
-> Result<(Self, usize), DecodeError>
|
||||||
{
|
{
|
||||||
if bytes.len() < 32 || bytes.len() - 32 < index {
|
if bytes.len() < 32 || bytes.len() - 32 < index {
|
||||||
return Err(DecodeError::TooShort)
|
Err(DecodeError::TooShort)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Ok((H256::from(&bytes[index..(index + 32)]),
|
Ok((H256::from(&bytes[index..(index + 32)]), index + 32))
|
||||||
index + 32));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user