Skip to content

Commit

Permalink
feat: phase out environment trait (#5439)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 15, 2023
1 parent de0cca2 commit dc72cad
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 227 deletions.
4 changes: 2 additions & 2 deletions bin/reth/src/db/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, open_db_read_only, table::Table, transaction::DbTx,
AccountChangeSet, AccountHistory, AccountsTrie, BlockBodyIndices, BlockOmmers,
BlockWithdrawals, Bytecodes, CanonicalHeaders, DatabaseEnvRO, HashedAccount, HashedStorage,
BlockWithdrawals, Bytecodes, CanonicalHeaders, DatabaseEnv, HashedAccount, HashedStorage,
HeaderNumbers, HeaderTD, Headers, PlainAccountState, PlainStorageState, PruneCheckpoints,
Receipts, StorageChangeSet, StorageHistory, StoragesTrie, SyncStage, SyncStageProgress, Tables,
TransactionBlock, Transactions, TxHashNumber, TxSenders,
Expand Down Expand Up @@ -58,7 +58,7 @@ impl Command {
///
/// The discrepancies and extra elements, along with a brief summary of the diff results are
/// then written to a file in the output directory.
pub fn execute(self, tool: &DbTool<'_, DatabaseEnvRO>) -> eyre::Result<()> {
pub fn execute(self, tool: &DbTool<'_, DatabaseEnv>) -> eyre::Result<()> {
// open second db
let second_db_path: PathBuf = self.secondary_datadir.join("db").into();
let second_db = open_db_read_only(&second_db_path, self.second_db.log_level)?;
Expand Down
6 changes: 3 additions & 3 deletions bin/reth/src/db/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::tui::DbListTUI;
use crate::utils::{DbTool, ListFilter};
use clap::Parser;
use eyre::WrapErr;
use reth_db::{database::Database, table::Table, DatabaseEnvRO, RawValue, TableViewer, Tables};
use reth_db::{database::Database, table::Table, DatabaseEnv, RawValue, TableViewer, Tables};
use reth_primitives::hex;
use std::cell::RefCell;
use tracing::error;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct Command {

impl Command {
/// Execute `db list` command
pub fn execute(self, tool: &DbTool<'_, DatabaseEnvRO>) -> eyre::Result<()> {
pub fn execute(self, tool: &DbTool<'_, DatabaseEnv>) -> eyre::Result<()> {
self.table.view(&ListTableViewer { tool, args: &self })
}

Expand Down Expand Up @@ -81,7 +81,7 @@ impl Command {
}

struct ListTableViewer<'a> {
tool: &'a DbTool<'a, DatabaseEnvRO>,
tool: &'a DbTool<'a, DatabaseEnv>,
args: &'a Command,
}

Expand Down
6 changes: 3 additions & 3 deletions bin/reth/src/db/snapshots/bench.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reth_db::DatabaseEnvRO;
use reth_db::DatabaseEnv;
use reth_primitives::{
snapshot::{Compression, Filters},
ChainSpec, SnapshotSegment,
Expand All @@ -16,7 +16,7 @@ pub(crate) enum BenchKind {

pub(crate) fn bench<F1, F2, R>(
bench_kind: BenchKind,
db: (DatabaseEnvRO, Arc<ChainSpec>),
db: (DatabaseEnv, Arc<ChainSpec>),
segment: SnapshotSegment,
filters: Filters,
compression: Compression,
Expand All @@ -25,7 +25,7 @@ pub(crate) fn bench<F1, F2, R>(
) -> eyre::Result<()>
where
F1: FnMut() -> eyre::Result<R>,
F2: Fn(DatabaseProviderRO<'_, DatabaseEnvRO>) -> eyre::Result<R>,
F2: Fn(DatabaseProviderRO<'_, DatabaseEnv>) -> eyre::Result<R>,
R: Debug + PartialEq,
{
let (db, chain) = db;
Expand Down
19 changes: 9 additions & 10 deletions bin/reth/src/db/snapshots/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use itertools::Itertools;
use reth_db::{open_db_read_only, DatabaseEnvRO};
use reth_db::{open_db_read_only, DatabaseEnv};
use reth_interfaces::db::LogLevel;
use reth_primitives::{
snapshot::{Compression, InclusionFilter, PerfectHashingFunction},
Expand Down Expand Up @@ -71,22 +71,21 @@ impl Command {
if !self.only_bench {
for ((mode, compression), phf) in all_combinations.clone() {
match mode {
SnapshotSegment::Headers => self
.generate_headers_snapshot::<DatabaseEnvRO>(
&provider,
*compression,
InclusionFilter::Cuckoo,
*phf,
)?,
SnapshotSegment::Headers => self.generate_headers_snapshot::<DatabaseEnv>(
&provider,
*compression,
InclusionFilter::Cuckoo,
*phf,
)?,
SnapshotSegment::Transactions => self
.generate_transactions_snapshot::<DatabaseEnvRO>(
.generate_transactions_snapshot::<DatabaseEnv>(
&provider,
*compression,
InclusionFilter::Cuckoo,
*phf,
)?,
SnapshotSegment::Receipts => self
.generate_receipts_snapshot::<DatabaseEnvRO>(
.generate_receipts_snapshot::<DatabaseEnv>(
&provider,
*compression,
InclusionFilter::Cuckoo,
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus/beacon/src/engine/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ mod tests {
use assert_matches::assert_matches;
use futures::poll;
use reth_db::{
mdbx::{Env, WriteMap},
mdbx::DatabaseEnv,
test_utils::{create_test_rw_db, TempDatabase},
};
use reth_interfaces::{p2p::either::EitherDownloader, test_utils::TestFullBlockClient};
Expand Down Expand Up @@ -449,7 +449,7 @@ mod tests {
}

/// Builds the pipeline.
fn build(self, chain_spec: Arc<ChainSpec>) -> Pipeline<Arc<TempDatabase<Env<WriteMap>>>> {
fn build(self, chain_spec: Arc<ChainSpec>) -> Pipeline<Arc<TempDatabase<DatabaseEnv>>> {
reth_tracing::init_test_tracing();
let db = create_test_rw_db();

Expand Down
Loading

0 comments on commit dc72cad

Please sign in to comment.