1#![doc(
4 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
5 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
6 issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
7)]
8#![cfg_attr(not(test), warn(unused_crate_dependencies))]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10#![cfg_attr(not(feature = "std"), no_std)]
11
12extern crate alloc;
13
14mod id;
15use alloy_primitives::{BlockHash, BlockNumber};
16pub use id::StageId;
17
18mod checkpoints;
19pub use checkpoints::{
20 AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint,
21 HeadersCheckpoint, IndexHistoryCheckpoint, MerkleCheckpoint, StageCheckpoint,
22 StageUnitCheckpoint, StorageHashingCheckpoint, StorageRootMerkleCheckpoint,
23};
24
25mod execution;
26pub use execution::*;
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum PipelineTarget {
31 Sync(BlockHash),
33 Unwind(BlockNumber),
35}
36
37impl PipelineTarget {
38 pub const fn sync_target(self) -> Option<BlockHash> {
45 match self {
46 Self::Sync(hash) => Some(hash),
47 Self::Unwind(_) => None,
48 }
49 }
50
51 pub const fn unwind_target(self) -> Option<BlockNumber> {
58 match self {
59 Self::Sync(_) => None,
60 Self::Unwind(number) => Some(number),
61 }
62 }
63}
64
65impl From<BlockHash> for PipelineTarget {
66 fn from(hash: BlockHash) -> Self {
67 Self::Sync(hash)
68 }
69}
70
71impl core::fmt::Display for PipelineTarget {
72 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73 match self {
74 Self::Sync(block) => {
75 write!(f, "Sync({block})")
76 }
77 Self::Unwind(block) => write!(f, "Unwind({block})"),
78 }
79 }
80}