@@ -6,10 +6,15 @@ use starknet_api::hash::HashOutput;
66use starknet_patricia:: db_layout:: { NodeLayout , TrieType } ;
77use starknet_patricia:: patricia_merkle_tree:: filled_tree:: node:: FilledNode ;
88use starknet_patricia:: patricia_merkle_tree:: filled_tree:: tree:: FilledTree ;
9+ use starknet_patricia:: patricia_merkle_tree:: node_data:: inner_node:: {
10+ BinaryData ,
11+ EdgeData ,
12+ NodeData ,
13+ } ;
914use starknet_patricia:: patricia_merkle_tree:: node_data:: leaf:: { Leaf , LeafModifications } ;
1015use starknet_patricia:: patricia_merkle_tree:: types:: { NodeIndex , SortedLeafIndices } ;
1116use starknet_patricia:: patricia_merkle_tree:: updated_skeleton_tree:: hash_function:: TreeHashFunction ;
12- use starknet_patricia_storage:: db_object:: { EmptyKeyContext , HasStaticPrefix } ;
17+ use starknet_patricia_storage:: db_object:: HasStaticPrefix ;
1318use starknet_patricia_storage:: errors:: SerializationResult ;
1419use starknet_patricia_storage:: storage_trait:: { DbHashMap , DbKey , Storage } ;
1520
6671 fn get_filled_node ( node_db_object : Self :: NodeDbObject ) -> FilledNode < L , Self :: NodeData > {
6772 node_db_object. 0
6873 }
74+
75+ fn get_db_object (
76+ hash : HashOutput ,
77+ filled_node_data : NodeData < L , HashOutput > ,
78+ ) -> Self :: NodeDbObject {
79+ IndexFilledNode ( FilledNode { hash, data : dump_child_hashes ( filled_node_data) } )
80+ }
81+
82+ fn get_node_suffix ( index : NodeIndex , _node_db_object : & Self :: NodeDbObject ) -> Vec < u8 > {
83+ index. 0 . to_be_bytes ( ) . to_vec ( )
84+ }
6985}
7086
7187// TODO(Ariel): define an IndexDbInitialRead empty type, and check whether each tree is empty inside
@@ -151,3 +167,15 @@ impl<S: Storage> ForestMetadata for IndexDb<S> {
151167 DbKey ( vec ! [ 0 ] )
152168 }
153169}
170+
171+ fn dump_child_hashes < L : Leaf > ( data : NodeData < L , HashOutput > ) -> NodeData < L , ( ) > {
172+ match data {
173+ NodeData :: Leaf ( leaf) => NodeData :: Leaf ( leaf) ,
174+
175+ NodeData :: Binary ( _) => NodeData :: Binary ( BinaryData { left_data : ( ) , right_data : ( ) } ) ,
176+
177+ NodeData :: Edge ( edge_data) => {
178+ NodeData :: Edge ( EdgeData { bottom_data : ( ) , path_to_bottom : edge_data. path_to_bottom } )
179+ }
180+ }
181+ }
0 commit comments