11//! Public module for share clap pieces to reduce duplication
22
3- use std:: num:: { NonZeroU32 , NonZeroU64 } ;
3+ use std:: num:: { NonZeroU32 , NonZeroU64 , NonZeroUsize } ;
44use std:: time:: Duration ;
55
66#[ cfg( feature = "rocksdb" ) ]
@@ -14,6 +14,7 @@ const DEFAULT_MAX_CONNECTION_AGE: Duration = Duration::from_mins(30);
1414const DEFAULT_REPLENISH_N_PER_SECOND_PER_IP : NonZeroU64 = NonZeroU64 :: new ( 16 ) . unwrap ( ) ;
1515const DEFAULT_BURST_SIZE : NonZeroU32 = NonZeroU32 :: new ( 128 ) . unwrap ( ) ;
1616const DEFAULT_MAX_CONCURRENT_CONNECTIONS : u64 = 1_000 ;
17+ const DEFAULT_SQLITE_POOL_SIZE : NonZeroUsize = NonZeroUsize :: new ( 16 ) . unwrap ( ) ;
1718
1819// Formats a Duration into a human-readable string for display in clap help text
1920// and yields a &'static str by _leaking_ the string deliberately.
@@ -141,8 +142,17 @@ impl GrpcOptionsExternal {
141142/// Collection of per usage storage backend configurations.
142143///
143144/// Note: Currently only contains `rocksdb` related configuration.
144- #[ derive( clap:: Args , Clone , Debug , Default , PartialEq , Eq ) ]
145+ #[ derive( clap:: Args , Clone , Debug , PartialEq , Eq ) ]
145146pub struct StorageOptions {
147+ /// Maximum number of SQLite connections in the async pool.
148+ #[ arg(
149+ long = "sqlite.pool_size" ,
150+ env = "MIDEN_NODE_SQLITE_POOL_SIZE" ,
151+ default_value_t = DEFAULT_SQLITE_POOL_SIZE ,
152+ value_name = "NUM"
153+ ) ]
154+ pub sqlite_pool_size : NonZeroUsize ,
155+
146156 #[ cfg( feature = "rocksdb" ) ]
147157 #[ clap( flatten) ]
148158 pub account_tree : AccountTreeRocksDbOptions ,
@@ -168,9 +178,26 @@ impl StorageOptions {
168178 cache_size_in_bytes : DEFAULT_ROCKSDB_CACHE_SIZE ,
169179 durability_mode : None ,
170180 } ;
171- Self { account_tree, nullifier_tree }
181+ Self { sqlite_pool_size : DEFAULT_SQLITE_POOL_SIZE , account_tree, nullifier_tree }
172182 }
173183 #[ cfg( not( feature = "rocksdb" ) ) ]
174184 Self :: default ( )
175185 }
176186}
187+
188+ impl Default for StorageOptions {
189+ fn default ( ) -> Self {
190+ #[ cfg( feature = "rocksdb" ) ]
191+ {
192+ Self {
193+ sqlite_pool_size : DEFAULT_SQLITE_POOL_SIZE ,
194+ account_tree : AccountTreeRocksDbOptions :: default ( ) ,
195+ nullifier_tree : NullifierTreeRocksDbOptions :: default ( ) ,
196+ }
197+ }
198+ #[ cfg( not( feature = "rocksdb" ) ) ]
199+ {
200+ Self { sqlite_pool_size : DEFAULT_SQLITE_POOL_SIZE }
201+ }
202+ }
203+ }
0 commit comments