reth_engine_tree/tree/
config.rs1pub const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2;
5
6pub const DEFAULT_BACKUP_THRESHOLD: u64 = 10;
8
9pub const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 2;
11
12const DEFAULT_BLOCK_BUFFER_LIMIT: u32 = 256;
13const DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH: u32 = 256;
14
15const DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE: usize = 4;
16
17#[derive(Debug)]
19pub struct TreeConfig {
20 persistence_threshold: u64,
23 memory_block_buffer_target: u64,
28 block_buffer_limit: u32,
31 max_invalid_header_cache_length: u32,
33 max_execute_block_batch_size: usize,
38 backup_threshold: u64,
40}
41
42impl Default for TreeConfig {
43 fn default() -> Self {
44 Self {
45 persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD,
46 memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
47 block_buffer_limit: DEFAULT_BLOCK_BUFFER_LIMIT,
48 max_invalid_header_cache_length: DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH,
49 max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE,
50 backup_threshold: DEFAULT_BACKUP_THRESHOLD,
51 }
52 }
53}
54
55impl TreeConfig {
56 pub const fn new(
58 persistence_threshold: u64,
59 memory_block_buffer_target: u64,
60 block_buffer_limit: u32,
61 max_invalid_header_cache_length: u32,
62 max_execute_block_batch_size: usize,
63 backup_threshold: u64,
64 ) -> Self {
65 Self {
66 persistence_threshold,
67 memory_block_buffer_target,
68 block_buffer_limit,
69 max_invalid_header_cache_length,
70 max_execute_block_batch_size,
71 backup_threshold,
72 }
73 }
74
75 pub const fn persistence_threshold(&self) -> u64 {
77 self.persistence_threshold
78 }
79
80 pub const fn memory_block_buffer_target(&self) -> u64 {
82 self.memory_block_buffer_target
83 }
84
85 pub const fn block_buffer_limit(&self) -> u32 {
87 self.block_buffer_limit
88 }
89
90 pub const fn max_invalid_header_cache_length(&self) -> u32 {
92 self.max_invalid_header_cache_length
93 }
94
95 pub const fn max_execute_block_batch_size(&self) -> usize {
97 self.max_execute_block_batch_size
98 }
99
100 pub const fn backup_threshold(&self) -> u64 {
102 self.backup_threshold
103 }
104
105 pub const fn with_persistence_threshold(mut self, persistence_threshold: u64) -> Self {
107 self.persistence_threshold = persistence_threshold;
108 self
109 }
110
111 pub const fn with_memory_block_buffer_target(
113 mut self,
114 memory_block_buffer_target: u64,
115 ) -> Self {
116 self.memory_block_buffer_target = memory_block_buffer_target;
117 self
118 }
119
120 pub const fn with_block_buffer_limit(mut self, block_buffer_limit: u32) -> Self {
122 self.block_buffer_limit = block_buffer_limit;
123 self
124 }
125
126 pub const fn with_max_invalid_header_cache_length(
128 mut self,
129 max_invalid_header_cache_length: u32,
130 ) -> Self {
131 self.max_invalid_header_cache_length = max_invalid_header_cache_length;
132 self
133 }
134
135 pub const fn with_max_execute_block_batch_size(
137 mut self,
138 max_execute_block_batch_size: usize,
139 ) -> Self {
140 self.max_execute_block_batch_size = max_execute_block_batch_size;
141 self
142 }
143
144 pub const fn with_backup_threshold(mut self, backup_threshold: u64) -> Self {
146 self.backup_threshold = backup_threshold;
147 self
148 }
149}