Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move traits for safe and finalized block read/write #12786

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions crates/storage/provider/src/traits/finalized_block.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/storage/provider/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ pub use full::{FullProvider, FullRpcProvider};

mod tree_viewer;
pub use tree_viewer::TreeViewer;

mod finalized_block;
pub use finalized_block::{ChainStateBlockReader, ChainStateBlockWriter};
21 changes: 21 additions & 0 deletions crates/storage/storage-api/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,24 @@ pub trait BlockReaderIdExt: BlockReader + ReceiptProviderIdExt {
/// Returns `None` if block is not found.
fn ommers_by_id(&self, id: BlockId) -> ProviderResult<Option<Vec<Header>>>;
}

/// Functionality to read the last known chain blocks from the database.
pub trait ChainStateBlockReader: Send + Sync {
/// Returns the last finalized block number.
///
/// If no finalized block has been written yet, this returns `None`.
fn last_finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>>;
/// Returns the last safe block number.
///
/// If no safe block has been written yet, this returns `None`.
fn last_safe_block_number(&self) -> ProviderResult<Option<BlockNumber>>;
}

/// Functionality to write the last known chain blocks to the database.
pub trait ChainStateBlockWriter: Send + Sync {
/// Saves the given finalized block number in the DB.
fn save_finalized_block_number(&self, block_number: BlockNumber) -> ProviderResult<()>;

/// Saves the given safe block number in the DB.
fn save_safe_block_number(&self, block_number: BlockNumber) -> ProviderResult<()>;
}
Loading