reth_storage_api/
stage_checkpoint.rs

1use alloc::{string::String, vec::Vec};
2use alloy_primitives::BlockNumber;
3use reth_stages_types::{StageCheckpoint, StageId};
4use reth_storage_errors::provider::ProviderResult;
5
6/// The trait for fetching stage checkpoint related data.
7#[auto_impl::auto_impl(&, Arc)]
8pub trait StageCheckpointReader: Send + Sync {
9    /// Fetch the checkpoint for the given stage.
10    fn get_stage_checkpoint(&self, id: StageId) -> ProviderResult<Option<StageCheckpoint>>;
11
12    /// Get stage checkpoint progress.
13    fn get_stage_checkpoint_progress(&self, id: StageId) -> ProviderResult<Option<Vec<u8>>>;
14
15    /// Reads all stage checkpoints and returns a list with the name of the stage and the checkpoint
16    /// data.
17    fn get_all_checkpoints(&self) -> ProviderResult<Vec<(String, StageCheckpoint)>>;
18}
19
20/// The trait for updating stage checkpoint related data.
21#[auto_impl::auto_impl(&, Arc)]
22pub trait StageCheckpointWriter: Send + Sync {
23    /// Save stage checkpoint.
24    fn save_stage_checkpoint(&self, id: StageId, checkpoint: StageCheckpoint)
25        -> ProviderResult<()>;
26
27    /// Save stage checkpoint progress.
28    fn save_stage_checkpoint_progress(
29        &self,
30        id: StageId,
31        checkpoint: Vec<u8>,
32    ) -> ProviderResult<()>;
33
34    /// Update all pipeline sync stage progress.
35    fn update_pipeline_stages(
36        &self,
37        block_number: BlockNumber,
38        drop_stage_checkpoint: bool,
39    ) -> ProviderResult<()>;
40}