reth_stages_api/pipeline/
progress.rsuse crate::{util::opt, ControlFlow};
use alloy_primitives::BlockNumber;
#[derive(Debug, Default)]
pub(crate) struct PipelineProgress {
pub(crate) block_number: Option<BlockNumber>,
pub(crate) maximum_block_number: Option<BlockNumber>,
pub(crate) minimum_block_number: Option<BlockNumber>,
}
impl PipelineProgress {
pub(crate) fn update(&mut self, block_number: BlockNumber) {
self.block_number = Some(block_number);
self.minimum_block_number = opt::min(self.minimum_block_number, block_number);
self.maximum_block_number = opt::max(self.maximum_block_number, block_number);
}
pub(crate) const fn next_ctrl(&self) -> ControlFlow {
match self.block_number {
Some(block_number) => ControlFlow::Continue { block_number },
None => ControlFlow::NoProgress { block_number: None },
}
}
}