mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 00:28:20 -05:00
chore: rename variant of BlockSource (#9623)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -1948,7 +1948,7 @@ impl<TX: DbTx> BlockNumReader for DatabaseProvider<TX> {
|
||||
|
||||
impl<TX: DbTx> BlockReader for DatabaseProvider<TX> {
|
||||
fn find_block_by_hash(&self, hash: B256, source: BlockSource) -> ProviderResult<Option<Block>> {
|
||||
if source.is_database() {
|
||||
if source.is_canonical() {
|
||||
self.block(hash.into())
|
||||
} else {
|
||||
Ok(None)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user