@@ -10,6 +10,7 @@ use crate::{
1010 mem:: Mem , storage:: Storage as MerkleStorage , Graftable , Location , Position , Readable ,
1111 } ,
1212 qmdb:: {
13+ self ,
1314 any:: {
1415 self ,
1516 batch:: { lookup_sorted, DiffEntry , FloorScan } ,
@@ -176,7 +177,7 @@ struct BatchStorageAdapter<
176177
177178impl <
178179 ' a ,
179- F : Graftable ,
180+ F : Graftable + qmdb :: RootSpec ,
180181 D : Digest ,
181182 R : Readable < Family = F , Digest = D , Error = merkle:: Error < F > > ,
182183 S : MerkleStorage < F , Digest = D > ,
@@ -192,7 +193,7 @@ impl<
192193}
193194
194195impl <
195- F : Graftable ,
196+ F : Graftable + qmdb :: RootSpec ,
196197 D : Digest ,
197198 R : Readable < Family = F , Digest = D , Error = merkle:: Error < F > > ,
198199 S : MerkleStorage < F , Digest = D > ,
@@ -349,7 +350,7 @@ where
349350// Unordered get + merkleize.
350351impl < F , K , V , H , const N : usize > UnmerkleizedBatch < F , H , update:: Unordered < K , V > , N >
351352where
352- F : Graftable ,
353+ F : Graftable + qmdb :: RootSpec ,
353354 K : Key ,
354355 V : ValueEncoding ,
355356 H : Hasher ,
@@ -412,7 +413,7 @@ where
412413// Ordered get + merkleize.
413414impl < F , K , V , H , const N : usize > UnmerkleizedBatch < F , H , update:: Ordered < K , V > , N >
414415where
415- F : Graftable ,
416+ F : Graftable + qmdb :: RootSpec ,
416417 K : Key ,
417418 V : ValueEncoding ,
418419 H : Hasher ,
@@ -550,7 +551,7 @@ async fn compute_current_layer<F, E, U, C, I, H, const N: usize>(
550551 bitmap_parent : & BitmapBatch < N > ,
551552) -> Result < Arc < MerkleizedBatch < F , H :: Digest , U , N > > , Error < F > >
552553where
553- F : Graftable ,
554+ F : Graftable + qmdb :: RootSpec ,
554555 E : Context ,
555556 U : update:: Update + Send + Sync ,
556557 C : Contiguous < Item = Operation < F , U > > ,
@@ -674,6 +675,7 @@ where
674675 & bitmap_batch,
675676 & grafted_storage,
676677 partial,
678+ inner. new_inactivity_floor_loc ,
677679 & ops_root,
678680 )
679681 . await ?;
@@ -956,7 +958,7 @@ where
956958
957959impl < F , E , C , I , H , U , const N : usize > super :: db:: Db < F , E , C , I , H , U , N >
958960where
959- F : Graftable ,
961+ F : Graftable + qmdb :: RootSpec ,
960962 E : Context ,
961963 U : update:: Update + Send + Sync ,
962964 C : Contiguous < Item = Operation < F , U > > ,
@@ -1000,7 +1002,7 @@ mod trait_impls {
10001002 UnmerkleizedBatchTrait < CurrentDb < F , E , C , I , H , update:: Unordered < K , V > , N > >
10011003 for UnmerkleizedBatch < F , H , update:: Unordered < K , V > , N >
10021004 where
1003- F : Graftable ,
1005+ F : Graftable + qmdb :: RootSpec ,
10041006 K : Key ,
10051007 V : ValueEncoding + ' static ,
10061008 H : Hasher ,
@@ -1020,20 +1022,29 @@ mod trait_impls {
10201022 Self :: write ( self , key, value)
10211023 }
10221024
1023- fn merkleize (
1025+ async fn merkleize (
10241026 self ,
10251027 db : & CurrentDb < F , E , C , I , H , update:: Unordered < K , V > , N > ,
10261028 metadata : Option < V :: Value > ,
1027- ) -> impl Future < Output = Result < Self :: Merkleized , crate :: qmdb:: Error < F > > > {
1028- self . merkleize ( db, metadata)
1029+ ) -> Result < Self :: Merkleized , crate :: qmdb:: Error < F > > {
1030+ let Self {
1031+ inner,
1032+ grafted_parent,
1033+ bitmap_parent,
1034+ } = self ;
1035+ let scan = BitmapScan :: new ( & bitmap_parent) ;
1036+ let inner = inner
1037+ . merkleize_with_floor_scan ( & db. any , metadata, scan)
1038+ . await ?;
1039+ compute_current_layer ( inner, db, & grafted_parent, & bitmap_parent) . await
10291040 }
10301041 }
10311042
10321043 impl < F , K , V , H , E , C , I , const N : usize >
10331044 UnmerkleizedBatchTrait < CurrentDb < F , E , C , I , H , update:: Ordered < K , V > , N > >
10341045 for UnmerkleizedBatch < F , H , update:: Ordered < K , V > , N >
10351046 where
1036- F : Graftable ,
1047+ F : Graftable + qmdb :: RootSpec ,
10371048 K : Key ,
10381049 V : ValueEncoding + ' static ,
10391050 H : Hasher ,
@@ -1053,12 +1064,21 @@ mod trait_impls {
10531064 Self :: write ( self , key, value)
10541065 }
10551066
1056- fn merkleize (
1067+ async fn merkleize (
10571068 self ,
10581069 db : & CurrentDb < F , E , C , I , H , update:: Ordered < K , V > , N > ,
10591070 metadata : Option < V :: Value > ,
1060- ) -> impl Future < Output = Result < Self :: Merkleized , crate :: qmdb:: Error < F > > > {
1061- self . merkleize ( db, metadata)
1071+ ) -> Result < Self :: Merkleized , crate :: qmdb:: Error < F > > {
1072+ let Self {
1073+ inner,
1074+ grafted_parent,
1075+ bitmap_parent,
1076+ } = self ;
1077+ let scan = BitmapScan :: new ( & bitmap_parent) ;
1078+ let inner = inner
1079+ . merkleize_with_floor_scan ( & db. any , metadata, scan)
1080+ . await ?;
1081+ compute_current_layer ( inner, db, & grafted_parent, & bitmap_parent) . await
10621082 }
10631083 }
10641084
@@ -1077,7 +1097,7 @@ mod trait_impls {
10771097 impl < F , E , K , V , C , I , H , const N : usize > BatchableDb
10781098 for CurrentDb < F , E , C , I , H , update:: Unordered < K , V > , N >
10791099 where
1080- F : Graftable ,
1100+ F : Graftable + qmdb :: RootSpec ,
10811101 E : Context ,
10821102 K : Key ,
10831103 V : ValueEncoding + ' static ,
@@ -1094,22 +1114,22 @@ mod trait_impls {
10941114 type Batch = UnmerkleizedBatch < F , H , update:: Unordered < K , V > , N > ;
10951115
10961116 fn new_batch ( & self ) -> Self :: Batch {
1097- self . new_batch ( )
1117+ Self :: new_batch ( self )
10981118 }
10991119
11001120 fn apply_batch (
11011121 & mut self ,
11021122 batch : Self :: Merkleized ,
11031123 ) -> impl Future < Output = Result < core:: ops:: Range < Location < F > > , crate :: qmdb:: Error < F > > >
11041124 {
1105- self . apply_batch ( batch)
1125+ Self :: apply_batch ( self , batch)
11061126 }
11071127 }
11081128
11091129 impl < F , E , K , V , C , I , H , const N : usize > BatchableDb
11101130 for CurrentDb < F , E , C , I , H , update:: Ordered < K , V > , N >
11111131 where
1112- F : Graftable ,
1132+ F : Graftable + qmdb :: RootSpec ,
11131133 E : Context ,
11141134 K : Key ,
11151135 V : ValueEncoding + ' static ,
@@ -1126,15 +1146,15 @@ mod trait_impls {
11261146 type Batch = UnmerkleizedBatch < F , H , update:: Ordered < K , V > , N > ;
11271147
11281148 fn new_batch ( & self ) -> Self :: Batch {
1129- self . new_batch ( )
1149+ Self :: new_batch ( self )
11301150 }
11311151
11321152 fn apply_batch (
11331153 & mut self ,
11341154 batch : Self :: Merkleized ,
11351155 ) -> impl Future < Output = Result < core:: ops:: Range < Location < F > > , crate :: qmdb:: Error < F > > >
11361156 {
1137- self . apply_batch ( batch)
1157+ Self :: apply_batch ( self , batch)
11381158 }
11391159 }
11401160}
0 commit comments