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
use crate::config::SafetyRulesConfig;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct ConsensusConfig {
pub max_block_size: u64,
pub max_pruned_blocks_in_mem: usize,
pub mempool_executed_txn_timeout_ms: u64,
pub mempool_txn_pull_timeout_ms: u64,
pub round_initial_timeout_ms: u64,
pub safety_rules: SafetyRulesConfig,
pub sync_only: bool,
pub channel_size: usize,
pub use_quorum_store: bool,
pub quorum_store_pull_timeout_ms: u64,
pub quorum_store_poll_count: u64,
pub intra_consensus_channel_buffer_size: usize,
}
impl Default for ConsensusConfig {
fn default() -> ConsensusConfig {
ConsensusConfig {
max_block_size: 6000,
max_pruned_blocks_in_mem: 100,
mempool_executed_txn_timeout_ms: 1000,
mempool_txn_pull_timeout_ms: 1000,
round_initial_timeout_ms: 1000,
safety_rules: SafetyRulesConfig::default(),
sync_only: false,
channel_size: 30,
use_quorum_store: false,
quorum_store_pull_timeout_ms: 1000,
quorum_store_poll_count: 20,
intra_consensus_channel_buffer_size: 10,
}
}
}
impl ConsensusConfig {
pub fn set_data_dir(&mut self, data_dir: PathBuf) {
self.safety_rules.set_data_dir(data_dir);
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_config_serialization() {
let config = ConsensusConfig::default();
let s = serde_yaml::to_string(&config).unwrap();
serde_yaml::from_str::<ConsensusConfig>(&s).unwrap();
}
}