diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 8024601392..88803b844e 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -1948,7 +1948,7 @@ impl BlockNumReader for DatabaseProvider { impl BlockReader for DatabaseProvider { fn find_block_by_hash(&self, hash: B256, source: BlockSource) -> ProviderResult> { - if source.is_database() { + if source.is_canonical() { self.block(hash.into()) } else { Ok(None) diff --git a/crates/storage/provider/src/providers/mod.rs b/crates/storage/provider/src/providers/mod.rs index 330c880c7e..54738035f0 100644 --- a/crates/storage/provider/src/providers/mod.rs +++ b/crates/storage/provider/src/providers/mod.rs @@ -290,7 +290,7 @@ where block } BlockSource::Pending => self.tree.block_by_hash(hash).map(|block| block.unseal()), - BlockSource::Database => self.database.block_by_hash(hash)?, + BlockSource::Canonical => self.database.block_by_hash(hash)?, }; Ok(block) @@ -820,7 +820,7 @@ where // trait impl if Some(true) == hash.require_canonical { // check the database, canonical blocks are only stored in the database - self.find_block_by_hash(hash.block_hash, BlockSource::Database) + self.find_block_by_hash(hash.block_hash, BlockSource::Canonical) } else { self.block_by_hash(hash.block_hash) } diff --git a/crates/storage/storage-api/src/block.rs b/crates/storage/storage-api/src/block.rs index 3dc22de8ae..fe97fb3713 100644 --- a/crates/storage/storage-api/src/block.rs +++ b/crates/storage/storage-api/src/block.rs @@ -23,10 +23,10 @@ pub enum BlockSource { #[default] Any, /// The block was fetched from the pending block source, the blockchain tree that buffers - /// blocks that are not yet finalized. + /// blocks that are not yet part of the canonical chain. Pending, - /// The block was fetched from the database. - Database, + /// The block must be part of the canonical chain. + Canonical, } impl BlockSource { @@ -35,9 +35,9 @@ impl BlockSource { matches!(self, Self::Pending | Self::Any) } - /// Returns `true` if the block source is `Database` or `Any`. - pub const fn is_database(&self) -> bool { - matches!(self, Self::Database | Self::Any) + /// Returns `true` if the block source is `Canonical` or `Any`. + pub const fn is_canonical(&self) -> bool { + matches!(self, Self::Canonical | Self::Any) } }