cuprate_blockchain/
config.rs1use std::path::PathBuf;
3
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7use cuprate_helper::fs::CUPRATE_DATA_DIR;
8
9#[derive(Default, Debug, Clone, Copy, Eq, PartialEq)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub enum Persistence {
13 Buffer,
17 Sync,
21 #[default]
22 BufferThenSync,
26}
27
28#[derive(Debug, Clone, Eq, PartialEq)]
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31#[cfg_attr(feature = "serde", serde(deny_unknown_fields, default))]
32pub struct CacheSizes {
33 pub rct_outputs: u64,
34 pub tx_infos: u64,
35 pub block_infos: u64,
36 pub pruned_blobs: u64,
37 pub v1_prunable_blobs: u64,
38 pub prunable_blobs: u64,
39 pub prunable_tip: u64,
40}
41
42impl Default for CacheSizes {
43 fn default() -> Self {
44 Self {
45 rct_outputs: 100 * 1024 * 1024,
46 tx_infos: 1024 * 1024,
47 block_infos: 1024 * 1024,
48 pruned_blobs: 25 * 1024 * 1024,
49 v1_prunable_blobs: 8 * 1024,
50 prunable_blobs: 8 * 1024,
51 prunable_tip: 8 * 1024,
52 }
53 }
54}
55
56#[derive(Debug, Clone, PartialEq, Eq)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub struct Config {
61 pub blob_dir: PathBuf,
63 pub index_dir: PathBuf,
65 pub cache_sizes: CacheSizes,
67 pub prune: bool,
69 pub persistence: Persistence,
71}
72
73impl Default for Config {
74 fn default() -> Self {
75 Self {
76 blob_dir: CUPRATE_DATA_DIR.to_path_buf(),
77 index_dir: CUPRATE_DATA_DIR.to_path_buf(),
78 cache_sizes: CacheSizes::default(),
79 prune: false,
80 persistence: Persistence::default(),
81 }
82 }
83}