sc_cli/params/database_params.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19use crate::arg_enums::Database;
20use clap::Args;
21
22/// Parameters for database
23#[derive(Debug, Clone, PartialEq, Args)]
24pub struct DatabaseParams {
25 /// Select database backend to use.
26 #[arg(long, alias = "db", value_name = "DB", ignore_case = true, value_enum)]
27 pub database: Option<Database>,
28
29 /// Limit the memory the database cache can use.
30 #[arg(long = "db-cache", value_name = "MiB")]
31 pub database_cache_size: Option<usize>,
32}
33
34impl DatabaseParams {
35 /// Database backend
36 pub fn database(&self) -> Option<Database> {
37 self.database
38 }
39
40 /// Limit the memory the database cache can use.
41 pub fn database_cache_size(&self) -> Option<usize> {
42 self.database_cache_size
43 }
44}