simplify AccountsDb::new_with_config (#20473)

This commit is contained in:
Jeff Washington (jwash)
2021-10-06 11:41:23 -05:00
committed by GitHub
parent 7149c2da0d
commit 895b46e0c3

View File

@ -1558,30 +1558,23 @@ impl AccountsDb {
let accounts_hash_cache_path = accounts_db_config let accounts_hash_cache_path = accounts_db_config
.as_ref() .as_ref()
.and_then(|x| x.accounts_hash_cache_path.clone()); .and_then(|x| x.accounts_hash_cache_path.clone());
let mut new = if !paths.is_empty() { let paths_is_empty = paths.is_empty();
Self { let mut new = Self {
paths, paths,
temp_paths: None,
cluster_type: Some(*cluster_type), cluster_type: Some(*cluster_type),
account_indexes, account_indexes,
caching_enabled, caching_enabled,
shrink_ratio, shrink_ratio,
accounts_update_notifier, accounts_update_notifier,
..Self::default_with_accounts_index(accounts_index, accounts_hash_cache_path) ..Self::default_with_accounts_index(accounts_index, accounts_hash_cache_path)
} };
} else { if paths_is_empty {
// Create a temporary set of accounts directories, used primarily // Create a temporary set of accounts directories, used primarily
// for testing // for testing
let (temp_dirs, paths) = get_temp_accounts_paths(DEFAULT_NUM_DIRS).unwrap(); let (temp_dirs, paths) = get_temp_accounts_paths(DEFAULT_NUM_DIRS).unwrap();
Self { new.accounts_update_notifier = None;
paths, new.paths = paths;
temp_paths: Some(temp_dirs), new.temp_paths = Some(temp_dirs);
cluster_type: Some(*cluster_type),
account_indexes,
caching_enabled,
shrink_ratio,
..Self::default_with_accounts_index(accounts_index, accounts_hash_cache_path)
}
}; };
new.start_background_hasher(); new.start_background_hasher();