@@ -7,6 +7,7 @@ use clap::{Args, Parser, Subcommand};
77use starknet_committer_cli:: commands:: run_storage_benchmark;
88use starknet_patricia_storage:: map_storage:: { CachedStorage , MapStorage } ;
99use starknet_patricia_storage:: mdbx_storage:: MdbxStorage ;
10+ use starknet_patricia_storage:: storage_trait:: Storage ;
1011use tracing:: info;
1112use tracing:: level_filters:: LevelFilter ;
1213use tracing_subscriber:: reload:: Handle ;
@@ -99,56 +100,42 @@ pub async fn run_committer_cli(
99100 format ! ( "{data_path}/{storage_type:?}/checkpoints/{n_iterations}" )
100101 } ) ;
101102
102- match storage_type {
103- StorageType :: MapStorage => {
104- let storage = MapStorage :: default ( ) ;
105- run_storage_benchmark (
106- seed,
107- n_iterations,
108- n_diffs,
109- & output_dir,
110- None ,
111- storage,
112- checkpoint_interval,
113- )
114- . await ;
115- }
103+ let ( mut storage, checkpoint_dir) : ( Box < dyn Storage > , Option < & str > ) = match storage_type
104+ {
105+ StorageType :: MapStorage => ( Box :: new ( MapStorage :: default ( ) ) , None ) ,
116106 StorageType :: Mdbx => {
117107 let storage_path = storage_path
118108 . unwrap_or_else ( || format ! ( "{data_path}/storage/{storage_type:?}" ) ) ;
119109 fs:: create_dir_all ( & storage_path) . expect ( "Failed to create storage directory." ) ;
120- let storage = MdbxStorage :: open ( Path :: new ( & storage_path) ) . unwrap ( ) ;
121- run_storage_benchmark (
122- seed,
123- n_iterations,
124- n_diffs,
125- & output_dir,
110+ (
111+ Box :: new ( MdbxStorage :: open ( Path :: new ( & storage_path) ) . unwrap ( ) ) ,
126112 Some ( & checkpoint_dir) ,
127- storage,
128- checkpoint_interval,
129113 )
130- . await ;
131114 }
132115 StorageType :: CachedMdbx => {
133116 let storage_path = storage_path
134117 . unwrap_or_else ( || format ! ( "{data_path}/storage/{storage_type:?}" ) ) ;
135118 fs:: create_dir_all ( & storage_path) . expect ( "Failed to create storage directory." ) ;
136- let storage = CachedStorage :: new (
137- MdbxStorage :: open ( Path :: new ( & storage_path) ) . unwrap ( ) ,
138- NonZeroUsize :: new ( cache_size) . unwrap ( ) ,
139- ) ;
140- run_storage_benchmark (
141- seed,
142- n_iterations,
143- n_diffs,
144- & output_dir,
119+ (
120+ Box :: new ( CachedStorage :: new (
121+ MdbxStorage :: open ( Path :: new ( & storage_path) ) . unwrap ( ) ,
122+ NonZeroUsize :: new ( cache_size) . unwrap ( ) ,
123+ ) ) ,
145124 Some ( & checkpoint_dir) ,
146- storage,
147- checkpoint_interval,
148125 )
149- . await ;
150126 }
151- }
127+ } ;
128+
129+ run_storage_benchmark (
130+ seed,
131+ n_iterations,
132+ n_diffs,
133+ & output_dir,
134+ checkpoint_dir,
135+ & mut * storage,
136+ checkpoint_interval,
137+ )
138+ . await ;
152139 }
153140 }
154141}
0 commit comments