Skip to content

Commit

Permalink
chore: move traits for safe and finalized block read/write (#12786)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 22, 2024
1 parent 7f95f1b commit 0416550
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
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<()>;
}

0 comments on commit 0416550

Please sign in to comment.