fix indentations
This commit is contained in:
parent
0272f6384d
commit
41a5501309
|
@ -88,12 +88,18 @@ pub struct MemoryDB<H: KeyHasher, T> {
|
||||||
null_node_data: T,
|
null_node_data: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, H, T> Default for MemoryDB<H, T> where H: KeyHasher, H::Out: HeapSizeOf, T: From<&'a [u8]> {
|
impl<'a, H, T> Default for MemoryDB<H, T>
|
||||||
|
where
|
||||||
|
H: KeyHasher,
|
||||||
|
H::Out: HeapSizeOf,
|
||||||
|
T: From<&'a [u8]>
|
||||||
|
{
|
||||||
fn default() -> Self { Self::new() }
|
fn default() -> Self { Self::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, H, T> MemoryDB<H, T>
|
impl<'a, H, T> MemoryDB<H, T>
|
||||||
where H: KeyHasher,
|
where
|
||||||
|
H: KeyHasher,
|
||||||
H::Out: HeapSizeOf,
|
H::Out: HeapSizeOf,
|
||||||
T: From<&'a [u8]>,
|
T: From<&'a [u8]>,
|
||||||
{
|
{
|
||||||
|
@ -104,7 +110,8 @@ impl<'a, H, T> MemoryDB<H, T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, T> MemoryDB<H, T>
|
impl<H, T> MemoryDB<H, T>
|
||||||
where H: KeyHasher,
|
where
|
||||||
|
H: KeyHasher,
|
||||||
H::Out: HeapSizeOf,
|
H::Out: HeapSizeOf,
|
||||||
T: Default,
|
T: Default,
|
||||||
{
|
{
|
||||||
|
@ -208,7 +215,8 @@ impl<H: KeyHasher, T> MemoryDB<H, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, T> MemoryDB<H, T>
|
impl<H, T> MemoryDB<H, T>
|
||||||
where H: KeyHasher,
|
where
|
||||||
|
H: KeyHasher,
|
||||||
H::Out: HeapSizeOf,
|
H::Out: HeapSizeOf,
|
||||||
T: HeapSizeOf,
|
T: HeapSizeOf,
|
||||||
{
|
{
|
||||||
|
@ -219,7 +227,8 @@ impl<H, T> MemoryDB<H, T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, T> HashDB<H, T> for MemoryDB<H, T>
|
impl<H, T> HashDB<H, T> for MemoryDB<H, T>
|
||||||
where H: KeyHasher,
|
where
|
||||||
|
H: KeyHasher,
|
||||||
T: Default + PartialEq<T> + for<'a> From<&'a [u8]> + Send + Sync,
|
T: Default + PartialEq<T> + for<'a> From<&'a [u8]> + Send + Sync,
|
||||||
{
|
{
|
||||||
fn keys(&self) -> HashMap<H::Out, i32> {
|
fn keys(&self) -> HashMap<H::Out, i32> {
|
||||||
|
@ -312,7 +321,8 @@ impl<H, T> HashDB<H, T> for MemoryDB<H, T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, T> AsHashDB<H, T> for MemoryDB<H, T>
|
impl<H, T> AsHashDB<H, T> for MemoryDB<H, T>
|
||||||
where H: KeyHasher,
|
where
|
||||||
|
H: KeyHasher,
|
||||||
T: Default + PartialEq<T> + for<'a> From<&'a[u8]> + Send + Sync,
|
T: Default + PartialEq<T> + for<'a> From<&'a[u8]> + Send + Sync,
|
||||||
{
|
{
|
||||||
fn as_hashdb(&self) -> &HashDB<H, T> { self }
|
fn as_hashdb(&self) -> &HashDB<H, T> { self }
|
||||||
|
|
|
@ -77,10 +77,18 @@ enum Node<H> {
|
||||||
Branch(Box<[Option<NodeHandle<H>>; 16]>, Option<DBValue>)
|
Branch(Box<[Option<NodeHandle<H>>; 16]>, Option<DBValue>)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O> Node<O> where O: AsRef<[u8]> + AsMut<[u8]> + Default + Debug + PartialEq + Eq + Hash + Send + Sync + Clone + Copy {
|
impl<O> Node<O>
|
||||||
|
where
|
||||||
|
O: AsRef<[u8]> + AsMut<[u8]> + Default + Debug + PartialEq + Eq + Hash + Send + Sync + Clone + Copy
|
||||||
|
{
|
||||||
// load an inline node into memory or get the hash to do the lookup later.
|
// load an inline node into memory or get the hash to do the lookup later.
|
||||||
fn inline_or_hash<C, H>(node: &[u8], db: &HashDB<H, DBValue>, storage: &mut NodeStorage<H::Out>) -> NodeHandle<H::Out>
|
fn inline_or_hash<C, H>(
|
||||||
where C: NodeCodec<H>,
|
node: &[u8],
|
||||||
|
db: &HashDB<H, DBValue>,
|
||||||
|
storage: &mut NodeStorage<H::Out>
|
||||||
|
) -> NodeHandle<H::Out>
|
||||||
|
where
|
||||||
|
C: NodeCodec<H>,
|
||||||
H: Hasher<Out = O>,
|
H: Hasher<Out = O>,
|
||||||
{
|
{
|
||||||
C::try_decode_hash(&node)
|
C::try_decode_hash(&node)
|
||||||
|
@ -976,8 +984,15 @@ mod tests {
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
use DBValue;
|
use DBValue;
|
||||||
|
|
||||||
fn populate_trie<'db, H, C>(db: &'db mut HashDB<KeccakHasher, DBValue>, root: &'db mut H256, v: &[(Vec<u8>, Vec<u8>)]) -> TrieDBMut<'db>
|
fn populate_trie<'db, H, C>(
|
||||||
where H: Hasher, H::Out: Decodable + Encodable, C: NodeCodec<H>
|
db: &'db mut HashDB<KeccakHasher, DBValue>,
|
||||||
|
root: &'db mut H256,
|
||||||
|
v: &[(Vec<u8>, Vec<u8>)]
|
||||||
|
) -> TrieDBMut<'db>
|
||||||
|
where
|
||||||
|
H: Hasher,
|
||||||
|
H::Out: Decodable + Encodable,
|
||||||
|
C: NodeCodec<H>,
|
||||||
{
|
{
|
||||||
let mut t = TrieDBMut::new(db, root);
|
let mut t = TrieDBMut::new(db, root);
|
||||||
for i in 0..v.len() {
|
for i in 0..v.len() {
|
||||||
|
|
|
@ -266,7 +266,6 @@ impl RlpStream {
|
||||||
/// panic! if stream is not finished.
|
/// panic! if stream is not finished.
|
||||||
pub fn out(self) -> Vec<u8> {
|
pub fn out(self) -> Vec<u8> {
|
||||||
match self.is_finished() {
|
match self.is_finished() {
|
||||||
//true => self.encoder.out().into_vec(),
|
|
||||||
true => self.buffer,
|
true => self.buffer,
|
||||||
false => panic!()
|
false => panic!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ fn shared_prefix_len<T: Eq>(first: &[T], second: &[T]) -> usize {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn ordered_trie_root<H, I, A>(input: I) -> H::Out
|
pub fn ordered_trie_root<H, I, A>(input: I) -> H::Out
|
||||||
where I: IntoIterator<Item = A>,
|
where
|
||||||
|
I: IntoIterator<Item = A>,
|
||||||
A: AsRef<[u8]>,
|
A: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
<H as hashdb::Hasher>::Out: cmp::Ord + rlp::Encodable,
|
<H as hashdb::Hasher>::Out: cmp::Ord + rlp::Encodable,
|
||||||
|
@ -89,7 +90,8 @@ pub fn ordered_trie_root<H, I, A>(input: I) -> H::Out
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn trie_root<H, I, A, B>(input: I) -> H::Out
|
pub fn trie_root<H, I, A, B>(input: I) -> H::Out
|
||||||
where I: IntoIterator<Item = (A, B)>,
|
where
|
||||||
|
I: IntoIterator<Item = (A, B)>,
|
||||||
A: AsRef<[u8]> + Ord,
|
A: AsRef<[u8]> + Ord,
|
||||||
B: AsRef<[u8]>,
|
B: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
|
@ -127,7 +129,8 @@ pub fn trie_root<H, I, A, B>(input: I) -> H::Out
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn sec_trie_root<H, I, A, B>(input: I) -> H::Out
|
pub fn sec_trie_root<H, I, A, B>(input: I) -> H::Out
|
||||||
where I: IntoIterator<Item = (A, B)>,
|
where
|
||||||
|
I: IntoIterator<Item = (A, B)>,
|
||||||
A: AsRef<[u8]>,
|
A: AsRef<[u8]>,
|
||||||
B: AsRef<[u8]>,
|
B: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
|
@ -147,7 +150,7 @@ pub fn sec_trie_root<H, I, A, B>(input: I) -> H::Out
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_trie_root<H, A, B>(input: &[(A, B)]) -> H::Out
|
fn gen_trie_root<H, A, B>(input: &[(A, B)]) -> H::Out
|
||||||
where
|
where
|
||||||
A: AsRef<[u8]>,
|
A: AsRef<[u8]>,
|
||||||
B: AsRef<[u8]>,
|
B: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
|
@ -214,7 +217,7 @@ fn as_nibbles(bytes: &[u8]) -> ElasticArray8<u8> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash256rlp<H, A, B>(input: &[(A, B)], pre_len: usize, stream: &mut RlpStream)
|
fn hash256rlp<H, A, B>(input: &[(A, B)], pre_len: usize, stream: &mut RlpStream)
|
||||||
where
|
where
|
||||||
A: AsRef<[u8]>,
|
A: AsRef<[u8]>,
|
||||||
B: AsRef<[u8]>,
|
B: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
|
@ -297,7 +300,7 @@ fn hash256rlp<H, A, B>(input: &[(A, B)], pre_len: usize, stream: &mut RlpStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash256aux<H, A, B>(input: &[(A, B)], pre_len: usize, stream: &mut RlpStream)
|
fn hash256aux<H, A, B>(input: &[(A, B)], pre_len: usize, stream: &mut RlpStream)
|
||||||
where
|
where
|
||||||
A: AsRef<[u8]>,
|
A: AsRef<[u8]>,
|
||||||
B: AsRef<[u8]>,
|
B: AsRef<[u8]>,
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
|
|
Loading…
Reference in New Issue