ckb_app_config/legacy/
store.rs

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
58
59
60
61
62
63
64
65
66
67
68
69
use serde::Deserialize;

#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub(crate) struct StoreConfig {
    header_cache_size: usize,
    cell_data_cache_size: usize,
    block_proposals_cache_size: usize,
    block_tx_hashes_cache_size: usize,
    block_uncles_cache_size: usize,
    pub(crate) cellbase_cache_size: Option<usize>,
    #[serde(default = "default_block_extensions_cache_size")]
    block_extensions_cache_size: usize,
    #[serde(default = "default_freezer_enable")]
    freezer_enable: bool,
}

const fn default_block_extensions_cache_size() -> usize {
    30
}

const fn default_freezer_enable() -> bool {
    false
}

impl Default for crate::StoreConfig {
    fn default() -> Self {
        StoreConfig::default().into()
    }
}

impl Default for StoreConfig {
    fn default() -> Self {
        Self {
            header_cache_size: 4096,
            cell_data_cache_size: 128,
            block_proposals_cache_size: 30,
            block_tx_hashes_cache_size: 30,
            block_uncles_cache_size: 30,
            cellbase_cache_size: None,
            block_extensions_cache_size: default_block_extensions_cache_size(),
            freezer_enable: default_freezer_enable(),
        }
    }
}

impl From<StoreConfig> for crate::StoreConfig {
    fn from(input: StoreConfig) -> Self {
        let StoreConfig {
            header_cache_size,
            cell_data_cache_size,
            block_proposals_cache_size,
            block_tx_hashes_cache_size,
            block_uncles_cache_size,
            cellbase_cache_size: _,
            block_extensions_cache_size,
            freezer_enable,
        } = input;
        Self {
            header_cache_size,
            cell_data_cache_size,
            block_proposals_cache_size,
            block_tx_hashes_cache_size,
            block_uncles_cache_size,
            block_extensions_cache_size,
            freezer_enable,
        }
    }
}