-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
A-dbRelated to the databaseRelated to the databaseC-enhancementNew feature or requestNew feature or requestD-good-first-issueNice and easy! A great choice to get startedNice and easy! A great choice to get started
Description
Describe the feature
we currently only have:
reth/crates/storage/storage-api/src/block.rs
Lines 76 to 79 in bec4510
/// Returns the block with given id from the database. | |
/// | |
/// Returns `None` if block is not found. | |
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>; |
and
reth/crates/storage/provider/src/providers/database/provider.rs
Lines 1181 to 1209 in bec4510
/// Returns the block with matching number from database. | |
/// | |
/// If the header for this block is not found, this returns `None`. | |
/// If the header is found, but the transactions either do not exist, or are not indexed, this | |
/// will return None. | |
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>> { | |
if let Some(number) = self.convert_hash_or_number(id)? { | |
if let Some(header) = self.header_by_number(number)? { | |
// If the body indices are not found, this means that the transactions either do not | |
// exist in the database yet, or they do exit but are not indexed. | |
// If they exist but are not indexed, we don't have enough | |
// information to return the block anyways, so we return `None`. | |
let Some(transactions) = self.transactions_by_block(number.into())? else { | |
return Ok(None) | |
}; | |
let body = self | |
.storage | |
.reader() | |
.read_block_bodies(self, vec![(&header, transactions)])? | |
.pop() | |
.ok_or(ProviderError::InvalidStorageOutput)?; | |
return Ok(Some(Self::Block::new(header, body))) | |
} | |
} | |
Ok(None) | |
} |
we can add another function dedicated to the blockbody
TODO
- add trait fn for block_body and impl it accordingly
Additional context
No response
Metadata
Metadata
Assignees
Labels
A-dbRelated to the databaseRelated to the databaseC-enhancementNew feature or requestNew feature or requestD-good-first-issueNice and easy! A great choice to get startedNice and easy! A great choice to get started
Type
Projects
Status
Backlog