Skip to content

Commit

Permalink
impl block_body_indices_range
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Jan 17, 2025
1 parent 0a6404f commit 66e07c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 9 additions & 6 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,12 +1633,15 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> BlockBodyIndicesProvider
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<StoredBlockBodyIndices>> {
Ok(self
.tx_ref()
.cursor_read::<tables::BlockBodyIndices>()?
.walk_range(range)?
.map(|r| r.map(|(_, b)| b))
.collect::<Result<_, _>>()?)
self.static_file_provider.get_range_with_static_file_or_database(
StaticFileSegment::BlockMeta,
*range.start()..*range.end()+1,
|static_file, range, _| {
static_file.block_body_indices_range(range.start..=range.end.saturating_sub(1))
},
|range, _| self.cursor_read_collect::<tables::BlockBodyIndices>(range),
|_| true,
)
}
}

Expand Down
14 changes: 9 additions & 5 deletions crates/storage/provider/src/providers/static_file/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use reth_chainspec::{ChainInfo, ChainSpecProvider};
use reth_db::{
lockfile::StorageLock,
static_file::{
iter_static_files, BlockHashMask, HeaderMask, HeaderWithHashMask, ReceiptMask,
StaticFileCursor, TDWithHashMask, TransactionMask,
iter_static_files, BlockHashMask, BodyIndicesMask, HeaderMask, HeaderWithHashMask,
ReceiptMask, StaticFileCursor, TDWithHashMask, TransactionMask,
},
table::{Decompress, Value},
tables,
Expand Down Expand Up @@ -1728,10 +1728,14 @@ impl<N: NodePrimitives> BlockBodyIndicesProvider for StaticFileProvider<N> {

fn block_body_indices_range(
&self,
_range: RangeInclusive<BlockNumber>,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<StoredBlockBodyIndices>> {
// Required data not present in static_files
Err(ProviderError::UnsupportedProvider)
self.fetch_range_with_predicate(
StaticFileSegment::BlockMeta,
*range.start()..*range.end() + 1,
|cursor, number| cursor.get_one::<BodyIndicesMask>(number.into()),
|_| true,
)
}
}

Expand Down

0 comments on commit 66e07c1

Please sign in to comment.