mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 13:54:44 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use super::*;
|
||||
use ethereum_types::{H160, H256, U128, U256};
|
||||
use smallvec::{smallvec, ToSmallVec};
|
||||
|
||||
fn int_to_hash256(int: u64) -> Hash256 {
|
||||
let mut bytes = [0; HASHSIZE];
|
||||
@@ -16,7 +15,7 @@ macro_rules! impl_for_bitsize {
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.to_le_bytes().to_smallvec()
|
||||
PackedEncoding::from_slice(&self.to_le_bytes())
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
@@ -89,9 +88,9 @@ impl TreeHash for U128 {
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
let mut result = smallvec![0; 16];
|
||||
let mut result = [0; 16];
|
||||
self.to_little_endian(&mut result);
|
||||
result
|
||||
PackedEncoding::from_slice(&result)
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
@@ -111,9 +110,9 @@ impl TreeHash for U256 {
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
let mut result = smallvec![0; 32];
|
||||
let mut result = [0; 32];
|
||||
self.to_little_endian(&mut result);
|
||||
result
|
||||
PackedEncoding::from_slice(&result)
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
@@ -133,9 +132,9 @@ impl TreeHash for H160 {
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
let mut result = smallvec![0; 32];
|
||||
let mut result = [0; 32];
|
||||
result[0..20].copy_from_slice(self.as_bytes());
|
||||
result
|
||||
PackedEncoding::from_slice(&result)
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
@@ -155,7 +154,7 @@ impl TreeHash for H256 {
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.as_bytes().to_smallvec()
|
||||
PackedEncoding::from_slice(self.as_bytes())
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
|
||||
@@ -14,9 +14,10 @@ pub const BYTES_PER_CHUNK: usize = 32;
|
||||
pub const HASHSIZE: usize = 32;
|
||||
pub const MERKLE_HASH_CHUNK: usize = 2 * BYTES_PER_CHUNK;
|
||||
pub const MAX_UNION_SELECTOR: u8 = 127;
|
||||
pub const SMALLVEC_SIZE: usize = 32;
|
||||
|
||||
pub type Hash256 = ethereum_types::H256;
|
||||
pub type PackedEncoding = SmallVec<[u8; BYTES_PER_CHUNK]>;
|
||||
pub type PackedEncoding = SmallVec<[u8; SMALLVEC_SIZE]>;
|
||||
|
||||
/// Convenience method for `MerkleHasher` which also provides some fast-paths for small trees.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user