Skip to content

Commit

Permalink
remove lifetime param in storage trait (paradigmxyz#5046)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsdan authored Oct 17, 2023
1 parent d3ea66b commit ede8278
Show file tree
Hide file tree
Showing 29 changed files with 212 additions and 303 deletions.
12 changes: 6 additions & 6 deletions bin/reth/src/db/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ impl Command {
}

/// Find diffs for a table, then analyzing the result
fn find_diffs<'a, T: Table>(
primary_tx: impl DbTx<'a>,
secondary_tx: impl DbTx<'a>,
fn find_diffs<T: Table>(
primary_tx: impl DbTx,
secondary_tx: impl DbTx,
output_dir: impl AsRef<Path>,
) -> eyre::Result<()>
where
Expand Down Expand Up @@ -231,9 +231,9 @@ where

/// This diff algorithm is slightly different, it will walk _each_ table, cross-checking for the
/// element in the other table.
fn find_diffs_advanced<'a, T: Table>(
primary_tx: &impl DbTx<'a>,
secondary_tx: &impl DbTx<'a>,
fn find_diffs_advanced<T: Table>(
primary_tx: &impl DbTx,
secondary_tx: &impl DbTx,
) -> eyre::Result<TableDiffResult<T>>
where
T::Value: PartialEq,
Expand Down
10 changes: 3 additions & 7 deletions crates/snapshot/src/segments/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ impl Headers {
}

// Generates the dataset to train a zstd dictionary with the most recent rows (at most 1000).
fn dataset_for_compression<'tx, T: Table<Key = BlockNumber>>(
fn dataset_for_compression<T: Table<Key = BlockNumber>>(
&self,
tx: &impl DbTx<'tx>,
tx: &impl DbTx,
range: &RangeInclusive<BlockNumber>,
range_len: usize,
) -> RethResult<Vec<Vec<u8>>> {
Expand All @@ -40,11 +40,7 @@ impl Headers {
}

impl Segment for Headers {
fn snapshot<'tx>(
&self,
tx: &impl DbTx<'tx>,
range: RangeInclusive<BlockNumber>,
) -> RethResult<()> {
fn snapshot(&self, tx: &impl DbTx, range: RangeInclusive<BlockNumber>) -> RethResult<()> {
let range_len = range.clone().count();
let mut jar = prepare_jar::<3, tables::Headers>(
tx,
Expand Down
10 changes: 3 additions & 7 deletions crates/snapshot/src/segments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ pub(crate) type Rows<const COLUMNS: usize> = [Vec<Vec<u8>>; COLUMNS];
/// A segment represents a snapshotting of some portion of the data.
pub trait Segment {
/// Snapshot data using the provided range.
fn snapshot<'tx>(
&self,
tx: &impl DbTx<'tx>,
range: RangeInclusive<BlockNumber>,
) -> RethResult<()>;
fn snapshot(&self, tx: &impl DbTx, range: RangeInclusive<BlockNumber>) -> RethResult<()>;
}

/// Returns a [`NippyJar`] according to the desired configuration.
pub(crate) fn prepare_jar<'tx, const COLUMNS: usize, T: Table>(
tx: &impl DbTx<'tx>,
pub(crate) fn prepare_jar<const COLUMNS: usize, T: Table>(
tx: &impl DbTx,
segment: SnapshotSegment,
filters: Filters,
compression: Compression,
Expand Down
4 changes: 2 additions & 2 deletions crates/stages/src/stages/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ mod tests {
.map_err(|e| e.into())
}

fn insert_storage_entry<'a, TX: DbTxMut<'a>>(
fn insert_storage_entry<TX: DbTxMut>(
&self,
tx: &'a TX,
tx: &TX,
tid_address: BlockNumberAddress,
entry: StorageEntry,
hash: bool,
Expand Down
5 changes: 1 addition & 4 deletions crates/stages/src/test_utils/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ impl TestTransaction {
}

/// Inserts a single [SealedHeader] into the corresponding tables of the headers stage.
fn insert_header<'a, TX: DbTxMut<'a> + DbTx<'a>>(
tx: &'a TX,
header: &SealedHeader,
) -> Result<(), DbError> {
fn insert_header<TX: DbTxMut + DbTx>(tx: &TX, header: &SealedHeader) -> Result<(), DbError> {
tx.put::<tables::CanonicalHeaders>(header.number, header.hash())?;
tx.put::<tables::HeaderNumbers>(header.hash(), header.number)?;
tx.put::<tables::Headers>(header.number, header.clone().unseal())
Expand Down
Loading

0 comments on commit ede8278

Please sign in to comment.