reth_stages_types/
execution.rs1use core::time::Duration;
2
3#[derive(Debug, Clone)]
8pub struct ExecutionStageThresholds {
9 pub max_blocks: Option<u64>,
11 pub max_changes: Option<u64>,
13 pub max_cumulative_gas: Option<u64>,
15 pub max_duration: Option<Duration>,
17}
18
19impl Default for ExecutionStageThresholds {
20 fn default() -> Self {
21 Self {
22 max_blocks: Some(500_000),
23 max_changes: Some(5_000_000),
24 max_cumulative_gas: Some(30_000_000 * 50_000),
26 max_duration: Some(Duration::from_secs(10 * 60)),
28 }
29 }
30}
31
32impl ExecutionStageThresholds {
33 #[inline]
35 pub fn is_end_of_batch(
36 &self,
37 blocks_processed: u64,
38 changes_processed: u64,
39 cumulative_gas_used: u64,
40 elapsed: Duration,
41 ) -> bool {
42 blocks_processed >= self.max_blocks.unwrap_or(u64::MAX) ||
43 changes_processed >= self.max_changes.unwrap_or(u64::MAX) ||
44 cumulative_gas_used >= self.max_cumulative_gas.unwrap_or(u64::MAX) ||
45 elapsed >= self.max_duration.unwrap_or(Duration::MAX)
46 }
47}