From 31a7a0614ecf2e47db92e7bd475cd2901fd11ecb Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 23 May 2019 23:34:49 +1000 Subject: [PATCH] Remove `bytes` dependency from shuffling --- eth2/utils/swap_or_not_shuffle/Cargo.toml | 1 - eth2/utils/swap_or_not_shuffle/src/shuffle_list.rs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/eth2/utils/swap_or_not_shuffle/Cargo.toml b/eth2/utils/swap_or_not_shuffle/Cargo.toml index 3a866da92..19d5444fb 100644 --- a/eth2/utils/swap_or_not_shuffle/Cargo.toml +++ b/eth2/utils/swap_or_not_shuffle/Cargo.toml @@ -15,6 +15,5 @@ hex = "0.3" ethereum-types = "0.5" [dependencies] -bytes = "0.4" hashing = { path = "../hashing" } int_to_bytes = { path = "../int_to_bytes" } diff --git a/eth2/utils/swap_or_not_shuffle/src/shuffle_list.rs b/eth2/utils/swap_or_not_shuffle/src/shuffle_list.rs index f60d793f2..96e100def 100644 --- a/eth2/utils/swap_or_not_shuffle/src/shuffle_list.rs +++ b/eth2/utils/swap_or_not_shuffle/src/shuffle_list.rs @@ -1,7 +1,5 @@ -use bytes::Buf; use hashing::hash; use int_to_bytes::int_to_bytes4; -use std::io::Cursor; const SEED_SIZE: usize = 32; const ROUND_SIZE: usize = 1; @@ -117,9 +115,10 @@ pub fn shuffle_list( Some(input) } -fn bytes_to_int64(bytes: &[u8]) -> u64 { - let mut cursor = Cursor::new(bytes); - cursor.get_u64_le() +fn bytes_to_int64(slice: &[u8]) -> u64 { + let mut bytes = [0; 8]; + bytes.copy_from_slice(&slice[0..8]); + u64::from_le_bytes(bytes) } #[cfg(test)]