Skip to content

Commit

Permalink
plural
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Dec 12, 2024
1 parent be16ac8 commit 43dc37b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 6 additions & 6 deletions crates/storage/db/src/static_file/masks.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
add_static_file_mask,
static_file::mask::{ColumnSelectorOne, ColumnSelectorTwo},
BlockBodyIndices, BlockOmmers, BlockWithdrawals, HeaderTerminalDifficulties,
BlockBodyIndices, BlockWithdrawals, HeaderTerminalDifficulties,
};
use alloy_primitives::BlockHash;
use reth_db_api::table::Table;
use reth_db_api::{models::StoredBlockOmmers, table::Table};

// HEADER MASKS
add_static_file_mask! {
Expand Down Expand Up @@ -46,13 +46,13 @@ add_static_file_mask! {
// BLOCK_META MASKS
add_static_file_mask! {
#[doc = "Mask for a `StoredBlockBodyIndices` from BlockMeta static file segment"]
BodyIndiceMask, <BlockBodyIndices as Table>::Value, 0b001
BodyIndicesMask, <BlockBodyIndices as Table>::Value, 0b001
}
add_static_file_mask! {
#[doc = "Mask for a `StoredBlockWithdrawals` from BlockMeta static file segment"]
OmmerMask<H>, H, 0b010
#[doc = "Mask for a `StoredBlockOmmers` from BlockMeta static file segment"]
OmmersMask<H>, StoredBlockOmmers<H>, 0b010
}
add_static_file_mask! {
#[doc = "Mask for a `StoredBlockWithdrawals` from BlockMeta static file segment"]
WithdrawalMask, <BlockWithdrawals as Table>::Value, 0b100
WithdrawalsMask, <BlockWithdrawals as Table>::Value, 0b100
}
14 changes: 6 additions & 8 deletions crates/storage/provider/src/providers/static_file/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ use reth_chainspec::ChainInfo;
use reth_db::{
models::StoredBlockBodyIndices,
static_file::{
BlockHashMask, BodyIndiceMask, HeaderMask, HeaderWithHashMask, OmmerMask, ReceiptMask,
StaticFileCursor, TDWithHashMask, TotalDifficultyMask, TransactionMask, WithdrawalMask,
BlockHashMask, BodyIndicesMask, HeaderMask, HeaderWithHashMask, OmmersMask, ReceiptMask,
StaticFileCursor, TDWithHashMask, TotalDifficultyMask, TransactionMask, WithdrawalsMask,
},
table::{Decompress, Value},
};
use reth_node_types::{FullNodePrimitives, NodePrimitives};
use reth_primitives::{transaction::recover_signers, SealedHeader, TransactionMeta};
use reth_primitives_traits::SignedTransaction;
use reth_storage_api::{
BlockBodyIndicesProvider, BlockReader, OmmersProvider, WithdrawalsProvider,
};
use reth_storage_api::{BlockBodyIndicesProvider, OmmersProvider, WithdrawalsProvider};
use reth_storage_errors::provider::{ProviderError, ProviderResult};
use std::{
fmt::Debug,
Expand Down Expand Up @@ -366,7 +364,7 @@ impl<N: NodePrimitives> WithdrawalsProvider for StaticFileJarProvider<'_, N> {
_: u64,
) -> ProviderResult<Option<Withdrawals>> {
if let Some(num) = id.as_number() {
return Ok(self.cursor()?.get_one::<WithdrawalMask>(num.into())?.map(|s| s.withdrawals))
return Ok(self.cursor()?.get_one::<WithdrawalsMask>(num.into())?.map(|s| s.withdrawals))
}
// Only accepts block number quries

Check failure on line 369 in crates/storage/provider/src/providers/static_file/jar.rs

View workflow job for this annotation

GitHub Actions / codespell

quries ==> queries
Err(ProviderError::UnsupportedProvider)
Expand All @@ -383,7 +381,7 @@ impl<N: FullNodePrimitives<BlockHeader: Value>> OmmersProvider for StaticFileJar
if let Some(num) = id.as_number() {
return Ok(self
.cursor()?
.get_one::<OmmerMask<Self::Header>>(num.into())?
.get_one::<OmmersMask<Self::Header>>(num.into())?
.map(|s| s.ommers))
}
// Only accepts block number quries

Check failure on line 387 in crates/storage/provider/src/providers/static_file/jar.rs

View workflow job for this annotation

GitHub Actions / codespell

quries ==> queries
Expand All @@ -393,6 +391,6 @@ impl<N: FullNodePrimitives<BlockHeader: Value>> OmmersProvider for StaticFileJar

impl<N: NodePrimitives> BlockBodyIndicesProvider for StaticFileJarProvider<'_, N> {
fn block_body_indices(&self, num: u64) -> ProviderResult<Option<StoredBlockBodyIndices>> {
self.cursor()?.get_one::<BodyIndiceMask>(num.into())
self.cursor()?.get_one::<BodyIndicesMask>(num.into())
}
}
4 changes: 2 additions & 2 deletions crates/storage/provider/src/providers/static_file/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,12 +1671,12 @@ impl<N: NodePrimitives> WithdrawalsProvider for StaticFileProvider<N> {
fn withdrawals_by_block(
&self,
id: BlockHashOrNumber,
_: u64,
timestamp: u64,
) -> ProviderResult<Option<Withdrawals>> {
if let Some(num) = id.as_number() {
return self
.get_segment_provider_from_block(StaticFileSegment::BlockMeta, num, None)
.and_then(|provider| provider.withdrawals_by_block(num))
.and_then(|provider| provider.withdrawals_by_block(id, timestamp))
.or_else(|err| {
if let ProviderError::MissingStaticFileBlock(_, _) = err {
Ok(None)
Expand Down

0 comments on commit 43dc37b

Please sign in to comment.