@@ -227,31 +227,46 @@ pub fn open_database<Block: BlockT>(
227227
228228 // and now open database assuming that it has the latest version
229229 let mut db_config = kvdb_rocksdb:: DatabaseConfig :: with_columns ( NUM_COLUMNS ) ;
230- let state_col_budget = ( * cache_size as f64 * 0.9 ) as usize ;
231- let other_col_budget = ( cache_size - state_col_budget) / ( NUM_COLUMNS as usize - 1 ) ;
232- let mut memory_budget = std:: collections:: HashMap :: new ( ) ;
233230 let path = path. to_str ( )
234231 . ok_or_else ( || sp_blockchain:: Error :: Backend ( "Invalid database path" . into ( ) ) ) ?;
235232
236- for i in 0 ..NUM_COLUMNS {
237- if i == crate :: columns:: STATE {
238- memory_budget. insert ( i, state_col_budget) ;
239- } else {
240- memory_budget. insert ( i, other_col_budget) ;
233+ let mut memory_budget = std:: collections:: HashMap :: new ( ) ;
234+ match db_type {
235+ DatabaseType :: Full => {
236+ let state_col_budget = ( * cache_size as f64 * 0.9 ) as usize ;
237+ let other_col_budget = ( cache_size - state_col_budget) / ( NUM_COLUMNS as usize - 1 ) ;
238+
239+ for i in 0 ..NUM_COLUMNS {
240+ if i == crate :: columns:: STATE {
241+ memory_budget. insert ( i, state_col_budget) ;
242+ } else {
243+ memory_budget. insert ( i, other_col_budget) ;
244+ }
245+ }
246+ log:: trace!(
247+ target: "db" ,
248+ "Open RocksDB database at {}, state column budget: {} MiB, others({}) column cache: {} MiB" ,
249+ path,
250+ state_col_budget,
251+ NUM_COLUMNS ,
252+ other_col_budget,
253+ ) ;
254+ } ,
255+ DatabaseType :: Light => {
256+ let col_budget = cache_size / ( NUM_COLUMNS as usize ) ;
257+ for i in 0 ..NUM_COLUMNS {
258+ memory_budget. insert ( i, col_budget) ;
259+ }
260+ log:: trace!(
261+ target: "db" ,
262+ "Open RocksDB light database at {}, column cache: {} MiB" ,
263+ path,
264+ col_budget,
265+ ) ;
241266 }
242267 }
243-
244268 db_config. memory_budget = memory_budget;
245269
246- log:: trace!(
247- target: "db" ,
248- "Open RocksDB database at {}, state column budget: {} MiB, others({}) column cache: {} MiB" ,
249- path,
250- state_col_budget,
251- NUM_COLUMNS ,
252- other_col_budget,
253- ) ;
254-
255270 let db = kvdb_rocksdb:: Database :: open ( & db_config, & path)
256271 . map_err ( |err| sp_blockchain:: Error :: Backend ( format ! ( "{}" , err) ) ) ?;
257272 sp_database:: as_database ( db)
@@ -262,7 +277,7 @@ pub fn open_database<Block: BlockT>(
262277 } ,
263278 #[ cfg( feature = "with-parity-db" ) ]
264279 DatabaseSettingsSrc :: ParityDb { path } => {
265- crate :: parity_db:: open ( & path)
280+ crate :: parity_db:: open ( & path, db_type )
266281 . map_err ( |e| sp_blockchain:: Error :: Backend ( format ! ( "{:?}" , e) ) ) ?
267282 } ,
268283 #[ cfg( not( feature = "with-parity-db" ) ) ]
0 commit comments