1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use datasize::DataSize;
use serde::{Deserialize, Serialize};
use casper_execution_engine::shared::utils;
const DEFAULT_MAX_GLOBAL_STATE_SIZE: usize = 805_306_368_000;
const DEFAULT_MAX_READERS: u32 = 512;
const DEFAULT_MAX_QUERY_DEPTH: u64 = 5;
#[derive(Clone, Copy, DataSize, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
max_global_state_size: Option<usize>,
max_readers: Option<u32>,
max_query_depth: Option<u64>,
}
impl Config {
pub(crate) fn max_global_state_size(&self) -> usize {
let value = self
.max_global_state_size
.unwrap_or(DEFAULT_MAX_GLOBAL_STATE_SIZE);
utils::check_multiple_of_page_size(value);
value
}
pub(crate) fn max_readers(&self) -> u32 {
self.max_readers.unwrap_or(DEFAULT_MAX_READERS)
}
pub(crate) fn max_query_depth(&self) -> u64 {
self.max_query_depth.unwrap_or(DEFAULT_MAX_QUERY_DEPTH)
}
}
impl Default for Config {
fn default() -> Self {
Config {
max_global_state_size: Some(DEFAULT_MAX_GLOBAL_STATE_SIZE),
max_readers: Some(DEFAULT_MAX_READERS),
max_query_depth: Some(DEFAULT_MAX_QUERY_DEPTH),
}
}
}