fix indentations

This commit is contained in:
Johann Tuffe 2018-08-23 16:49:01 +08:00
parent 0272f6384d
commit 41a5501309
4 changed files with 103 additions and 76 deletions

View File

@ -88,12 +88,18 @@ pub struct MemoryDB<H: KeyHasher, 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() }
}
impl<'a, H, T> MemoryDB<H, T>
where H: KeyHasher,
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: From<&'a [u8]>,
{
@ -104,7 +110,8 @@ impl<'a, H, T> MemoryDB<H, T>
}
impl<H, T> MemoryDB<H, T>
where H: KeyHasher,
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: Default,
{
@ -208,7 +215,8 @@ impl<H: KeyHasher, T> MemoryDB<H, T> {
}
impl<H, T> MemoryDB<H, T>
where H: KeyHasher,
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: HeapSizeOf,
{
@ -219,7 +227,8 @@ impl<H, T> 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,
{
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>
where H: KeyHasher,
where
H: KeyHasher,
T: Default + PartialEq<T> + for<'a> From<&'a[u8]> + Send + Sync,
{
fn as_hashdb(&self) -> &HashDB<H, T> { self }

View File

@ -77,10 +77,18 @@ enum Node<H> {
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.
fn inline_or_hash<C, H>(node: &[u8], db: &HashDB<H, DBValue>, storage: &mut NodeStorage<H::Out>) -> NodeHandle<H::Out>
where C: NodeCodec<H>,
fn inline_or_hash<C, H>(
node: &[u8],
db: &HashDB<H, DBValue>,
storage: &mut NodeStorage<H::Out>
) -> NodeHandle<H::Out>
where
C: NodeCodec<H>,
H: Hasher<Out = O>,
{
C::try_decode_hash(&node)
@ -976,8 +984,15 @@ mod tests {
use ethereum_types::H256;
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>
where H: Hasher, H::Out: Decodable + Encodable, C: NodeCodec<H>
fn populate_trie<'db, H, C>(
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);
for i in 0..v.len() {

View File

@ -266,7 +266,6 @@ impl RlpStream {
/// panic! if stream is not finished.
pub fn out(self) -> Vec<u8> {
match self.is_finished() {
//true => self.encoder.out().into_vec(),
true => self.buffer,
false => panic!()
}

View File

@ -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
where I: IntoIterator<Item = A>,
where
I: IntoIterator<Item = A>,
A: AsRef<[u8]>,
H: Hasher,
<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
where I: IntoIterator<Item = (A, B)>,
where
I: IntoIterator<Item = (A, B)>,
A: AsRef<[u8]> + Ord,
B: AsRef<[u8]>,
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
where I: IntoIterator<Item = (A, B)>,
where
I: IntoIterator<Item = (A, B)>,
A: AsRef<[u8]>,
B: AsRef<[u8]>,
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
where
where
A: AsRef<[u8]>,
B: AsRef<[u8]>,
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)
where
where
A: AsRef<[u8]>,
B: AsRef<[u8]>,
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)
where
where
A: AsRef<[u8]>,
B: AsRef<[u8]>,
H: Hasher,