Skip to content

Commit

Permalink
fix(provider): fix pending block retrieval in find_block_by_hash (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored Feb 7, 2025
1 parent 5a714cd commit d147a20
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/storage/provider/src/providers/consistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,22 +797,21 @@ impl<N: ProviderNodeTypes> BlockReader for ConsistentProvider<N> {
source: BlockSource,
) -> ProviderResult<Option<Self::Block>> {
if matches!(source, BlockSource::Canonical | BlockSource::Any) {
return self.get_in_memory_or_storage_by_block(
if let Some(block) = self.get_in_memory_or_storage_by_block(
hash.into(),
|db_provider| db_provider.find_block_by_hash(hash, BlockSource::Canonical),
|block_state| Ok(Some(block_state.block_ref().recovered_block().clone_block())),
)
)? {
return Ok(Some(block))
}
}

if matches!(source, BlockSource::Pending | BlockSource::Any) {
if let Some(block) = self
return Ok(self
.canonical_in_memory_state
.pending_block()
.filter(|b| b.hash() == hash)
.map(|b| b.into_block())
{
return Ok(Some(block))
}
.map(|b| b.into_block()))
}

Ok(None)
Expand Down

0 comments on commit d147a20

Please sign in to comment.