@@ -37,12 +37,12 @@ pub struct CascadingMerkleTree<H, S = Vec<<H as Hasher>::Hash>>
37
37
where
38
38
H : Hasher ,
39
39
{
40
- depth : usize ,
41
- root : H :: Hash ,
42
- empty_value : H :: Hash ,
40
+ depth : usize ,
41
+ root : H :: Hash ,
42
+ empty_value : H :: Hash ,
43
43
sparse_column : Vec < H :: Hash > ,
44
- storage : S ,
45
- _marker : std:: marker:: PhantomData < H > ,
44
+ storage : S ,
45
+ _marker : std:: marker:: PhantomData < H > ,
46
46
}
47
47
48
48
impl < H , S > CascadingMerkleTree < H , S >
@@ -587,12 +587,12 @@ mod tests {
587
587
let leaves = vec ! [ 1 ; num_leaves] ;
588
588
let tree = CascadingMerkleTree :: < TestHasher > :: new_with_leaves ( vec ! [ ] , 10 , & 0 , & leaves) ;
589
589
let expected = CascadingMerkleTree :: < TestHasher > {
590
- depth : 10 ,
591
- root : 5 ,
592
- empty_value : 0 ,
590
+ depth : 10 ,
591
+ root : 5 ,
592
+ empty_value : 0 ,
593
593
sparse_column : vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
594
- storage : vec ! [ 5 , 1 , 2 , 1 , 4 , 2 , 1 , 1 , 5 , 1 , 1 , 0 , 1 , 0 , 0 , 0 ] ,
595
- _marker : std:: marker:: PhantomData ,
594
+ storage : vec ! [ 5 , 1 , 2 , 1 , 4 , 2 , 1 , 1 , 5 , 1 , 1 , 0 , 1 , 0 , 0 , 0 ] ,
595
+ _marker : std:: marker:: PhantomData ,
596
596
} ;
597
597
debug_tree ( & tree) ;
598
598
tree. validate ( ) . unwrap ( ) ;
@@ -606,12 +606,12 @@ mod tests {
606
606
let empty = 0 ;
607
607
let tree = CascadingMerkleTree :: < TestHasher > :: new_with_leaves ( vec ! [ ] , 10 , & empty, & leaves) ;
608
608
let expected = CascadingMerkleTree :: < TestHasher > {
609
- depth : 10 ,
610
- root : 8 ,
611
- empty_value : 0 ,
609
+ depth : 10 ,
610
+ root : 8 ,
611
+ empty_value : 0 ,
612
612
sparse_column : vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
613
- storage : vec ! [ 8 , 1 , 2 , 1 , 4 , 2 , 1 , 1 , 8 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ] ,
614
- _marker : std:: marker:: PhantomData ,
613
+ storage : vec ! [ 8 , 1 , 2 , 1 , 4 , 2 , 1 , 1 , 8 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ] ,
614
+ _marker : std:: marker:: PhantomData ,
615
615
} ;
616
616
debug_tree ( & tree) ;
617
617
tree. validate ( ) . unwrap ( ) ;
@@ -624,12 +624,12 @@ mod tests {
624
624
let empty = 0 ;
625
625
let tree = CascadingMerkleTree :: < TestHasher > :: new_with_leaves ( vec ! [ ] , 10 , & empty, & leaves) ;
626
626
let expected = CascadingMerkleTree :: < TestHasher > {
627
- depth : 10 ,
628
- root : 0 ,
629
- empty_value : 0 ,
627
+ depth : 10 ,
628
+ root : 0 ,
629
+ empty_value : 0 ,
630
630
sparse_column : vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
631
- storage : vec ! [ 0 , 0 ] ,
632
- _marker : std:: marker:: PhantomData ,
631
+ storage : vec ! [ 0 , 0 ] ,
632
+ _marker : std:: marker:: PhantomData ,
633
633
} ;
634
634
debug_tree ( & tree) ;
635
635
tree. validate ( ) . unwrap ( ) ;
@@ -642,12 +642,12 @@ mod tests {
642
642
let empty = 1 ;
643
643
let tree = CascadingMerkleTree :: < TestHasher > :: new_with_leaves ( vec ! [ ] , 10 , & empty, & leaves) ;
644
644
let expected = CascadingMerkleTree :: < TestHasher > {
645
- depth : 10 ,
646
- root : 1024 ,
647
- empty_value : 1 ,
645
+ depth : 10 ,
646
+ root : 1024 ,
647
+ empty_value : 1 ,
648
648
sparse_column : vec ! [ 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 ] ,
649
- storage : vec ! [ 0 , 1 ] ,
650
- _marker : std:: marker:: PhantomData ,
649
+ storage : vec ! [ 0 , 1 ] ,
650
+ _marker : std:: marker:: PhantomData ,
651
651
} ;
652
652
debug_tree ( & tree) ;
653
653
tree. validate ( ) . unwrap ( ) ;
@@ -661,12 +661,12 @@ mod tests {
661
661
let empty = 1 ;
662
662
let tree = CascadingMerkleTree :: < TestHasher > :: new_with_leaves ( vec ! [ ] , 4 , & empty, & leaves) ;
663
663
let expected = CascadingMerkleTree :: < TestHasher > {
664
- depth : 4 ,
665
- root : 8 ,
666
- empty_value : 1 ,
664
+ depth : 4 ,
665
+ root : 8 ,
666
+ empty_value : 1 ,
667
667
sparse_column : vec ! [ 1 , 2 , 4 , 8 , 16 ] ,
668
- storage : vec ! [ 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
669
- _marker : std:: marker:: PhantomData ,
668
+ storage : vec ! [ 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
669
+ _marker : std:: marker:: PhantomData ,
670
670
} ;
671
671
debug_tree ( & tree) ;
672
672
tree. validate ( ) . unwrap ( ) ;
@@ -729,12 +729,9 @@ mod tests {
729
729
tree. validate ( ) . unwrap ( ) ;
730
730
debug_tree ( & tree) ;
731
731
let expected = vec ! [
732
- (
733
- 0 ,
734
- vec![
735
- 1usize , 3 , 6 , 7 , 12 , 13 , 14 , 15 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 ,
736
- ] ,
737
- ) ,
732
+ ( 0 , vec![
733
+ 1usize , 3 , 6 , 7 , 12 , 13 , 14 , 15 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 ,
734
+ ] ) ,
738
735
( 1 , vec![ 2 , 5 , 10 , 11 , 20 , 21 , 22 , 23 ] ) ,
739
736
( 2 , vec![ 4 , 9 , 18 , 19 ] ) ,
740
737
( 3 , vec![ 8 , 17 ] ) ,
@@ -782,60 +779,42 @@ mod tests {
782
779
debug_tree ( & tree) ;
783
780
tree. validate ( ) . unwrap ( ) ;
784
781
let expected = vec ! [
785
- (
786
- 1 ,
787
- vec![
788
- Branch :: Left ( 2 ) ,
789
- Branch :: Left ( 7 ) ,
790
- Branch :: Left ( 13 ) ,
791
- Branch :: Left ( 8 ) ,
792
- ] ,
793
- ) ,
794
- (
795
- 2 ,
796
- vec![
797
- Branch :: Right ( 1 ) ,
798
- Branch :: Left ( 7 ) ,
799
- Branch :: Left ( 13 ) ,
800
- Branch :: Left ( 8 ) ,
801
- ] ,
802
- ) ,
803
- (
804
- 3 ,
805
- vec![
806
- Branch :: Left ( 4 ) ,
807
- Branch :: Right ( 3 ) ,
808
- Branch :: Left ( 13 ) ,
809
- Branch :: Left ( 8 ) ,
810
- ] ,
811
- ) ,
812
- (
813
- 4 ,
814
- vec![
815
- Branch :: Right ( 3 ) ,
816
- Branch :: Right ( 3 ) ,
817
- Branch :: Left ( 13 ) ,
818
- Branch :: Left ( 8 ) ,
819
- ] ,
820
- ) ,
821
- (
822
- 5 ,
823
- vec![
824
- Branch :: Left ( 6 ) ,
825
- Branch :: Left ( 2 ) ,
826
- Branch :: Right ( 10 ) ,
827
- Branch :: Left ( 8 ) ,
828
- ] ,
829
- ) ,
830
- (
831
- 6 ,
832
- vec![
833
- Branch :: Right ( 5 ) ,
834
- Branch :: Left ( 2 ) ,
835
- Branch :: Right ( 10 ) ,
836
- Branch :: Left ( 8 ) ,
837
- ] ,
838
- ) ,
782
+ ( 1 , vec![
783
+ Branch :: Left ( 2 ) ,
784
+ Branch :: Left ( 7 ) ,
785
+ Branch :: Left ( 13 ) ,
786
+ Branch :: Left ( 8 ) ,
787
+ ] ) ,
788
+ ( 2 , vec![
789
+ Branch :: Right ( 1 ) ,
790
+ Branch :: Left ( 7 ) ,
791
+ Branch :: Left ( 13 ) ,
792
+ Branch :: Left ( 8 ) ,
793
+ ] ) ,
794
+ ( 3 , vec![
795
+ Branch :: Left ( 4 ) ,
796
+ Branch :: Right ( 3 ) ,
797
+ Branch :: Left ( 13 ) ,
798
+ Branch :: Left ( 8 ) ,
799
+ ] ) ,
800
+ ( 4 , vec![
801
+ Branch :: Right ( 3 ) ,
802
+ Branch :: Right ( 3 ) ,
803
+ Branch :: Left ( 13 ) ,
804
+ Branch :: Left ( 8 ) ,
805
+ ] ) ,
806
+ ( 5 , vec![
807
+ Branch :: Left ( 6 ) ,
808
+ Branch :: Left ( 2 ) ,
809
+ Branch :: Right ( 10 ) ,
810
+ Branch :: Left ( 8 ) ,
811
+ ] ) ,
812
+ ( 6 , vec![
813
+ Branch :: Right ( 5 ) ,
814
+ Branch :: Left ( 2 ) ,
815
+ Branch :: Right ( 10 ) ,
816
+ Branch :: Left ( 8 ) ,
817
+ ] ) ,
839
818
] ;
840
819
for ( leaf, expected_proof) in expected {
841
820
let proof = tree. proof_from_hash ( leaf) . unwrap ( ) ;
0 commit comments