chore: rename variant of BlockSource (#9623)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Miguel
2024-07-19 04:54:15 -03:00
committed by GitHub
parent ef0a447181
commit 85a4008b5a
3 changed files with 9 additions and 9 deletions

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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)
}
}