Skip to content
Snippets Groups Projects
Commit cd619294 authored by Wei Tang's avatar Wei Tang
Browse files

beacon: port back to_bytes/to_uint

parent 11013122
Branches
No related merge requests found
......@@ -4,6 +4,21 @@ mod serde;
#[cfg(feature = "serde")]
pub use self::serde::*;
use primitive_types::H256;
pub fn to_bytes(v: u64) -> H256 {
let bytes = v.to_le_bytes();
let mut ret = H256::default();
(&mut ret[0..bytes.len()]).copy_from_slice(&bytes);
ret
}
pub fn to_uint(v: &[u8]) -> u64 {
let mut ret = 0u64.to_le_bytes();
(&mut ret[..]).copy_from_slice(&v[..v.len()]);
u64::from_le_bytes(ret)
}
pub fn integer_squareroot(n: u64) -> u64 {
let mut x = n;
let mut y = (x + 1) / 2;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment