Finish implementing Darrens migrate-ssz-little-endian and add wrapper to check for ssz underflow

This commit is contained in:
Kirk Baird
2019-03-18 18:11:46 +11:00
parent 10efc9a934
commit 9cef6a5814
16 changed files with 114 additions and 73 deletions

View File

@@ -76,7 +76,7 @@ pub fn encode_length(len: usize, length_bytes: usize) -> Vec<u8> {
assert!((len as usize) < 2usize.pow(length_bytes as u32 * 8));
let mut header: Vec<u8> = vec![0; length_bytes];
for (i, header_byte) in header.iter_mut().enumerate() {
let offset = (length_bytes - (length_bytes - i)) * 8;
let offset = i * 8;
*header_byte = ((len >> offset) & 0xff) as u8;
}
header