Skip to content

Commit

Permalink
it compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jul 12, 2023
1 parent 5a63aa4 commit bd644cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl Command {
let pruner = config.prune.map(|prune_config| {
info!(target: "reth::cli", "Pruner initialized");
reth_prune::Pruner::new(
blockchain_db.clone(),
db.clone(),
self.chain.clone(),
prune_config.block_interval,
tree_config.max_reorg_depth(),
Expand Down
6 changes: 3 additions & 3 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ where
/// be used to download and execute the missing blocks.
pipeline_run_threshold: u64,
/// Controls pruning triggered by engine updates.
prune: Option<EnginePruneController>,
prune: Option<EnginePruneController<DB>>,
}

impl<DB, BT, Client> BeaconConsensusEngine<DB, BT, Client>
Expand All @@ -219,7 +219,7 @@ where
payload_builder: PayloadBuilderHandle,
target: Option<H256>,
pipeline_run_threshold: u64,
pruner: Option<Pruner>,
pruner: Option<Pruner<DB>>,
) -> Result<(Self, BeaconConsensusEngineHandle), Error> {
let (to_engine, rx) = mpsc::unbounded_channel();
Self::with_channel(
Expand Down Expand Up @@ -265,7 +265,7 @@ where
pipeline_run_threshold: u64,
to_engine: UnboundedSender<BeaconEngineMessage>,
rx: UnboundedReceiver<BeaconEngineMessage>,
pruner: Option<Pruner>,
pruner: Option<Pruner<DB>>,
) -> Result<(Self, BeaconConsensusEngineHandle), Error> {
let handle = BeaconConsensusEngineHandle { to_engine };
let sync = EngineSyncController::new(
Expand Down
17 changes: 9 additions & 8 deletions crates/consensus/beacon/src/engine/prune.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Prune management for the engine implementation.

use futures::FutureExt;
use reth_db::database::Database;
use reth_primitives::BlockNumber;
use reth_prune::{Pruner, PrunerError, PrunerWithResult};
use reth_tasks::TaskSpawner;
Expand All @@ -10,16 +11,16 @@ use tokio::sync::oneshot;
/// Manages pruning under the control of the engine.
///
/// This type controls the [Pruner].
pub(crate) struct EnginePruneController {
pub(crate) struct EnginePruneController<DB> {
/// The current state of the pruner.
pruner_state: PrunerState,
pruner_state: PrunerState<DB>,
/// The type that can spawn the pruner task.
pruner_task_spawner: Box<dyn TaskSpawner>,
}

impl EnginePruneController {
impl<DB: Database + 'static> EnginePruneController<DB> {
/// Create a new instance
pub(crate) fn new(pruner: Pruner, pruner_task_spawner: Box<dyn TaskSpawner>) -> Self {
pub(crate) fn new(pruner: Pruner<DB>, pruner_task_spawner: Box<dyn TaskSpawner>) -> Self {
Self { pruner_state: PrunerState::Idle(Some(pruner)), pruner_task_spawner }
}

Expand Down Expand Up @@ -131,14 +132,14 @@ pub(crate) enum EnginePruneEvent {
/// running, it acquires the write lock over the database. This means that we cannot forward to the
/// blockchain tree any messages that would result in database writes, since it would result in a
/// deadlock.
enum PrunerState {
enum PrunerState<DB> {
/// Pruner is idle.
Idle(Option<Pruner>),
Idle(Option<Pruner<DB>>),
/// Pruner is running and waiting for a response
Running(oneshot::Receiver<PrunerWithResult>),
Running(oneshot::Receiver<PrunerWithResult<DB>>),
}

impl PrunerState {
impl<DB> PrunerState<DB> {
/// Returns `true` if the state matches idle.
fn is_idle(&self) -> bool {
matches!(self, PrunerState::Idle(_))
Expand Down
2 changes: 1 addition & 1 deletion crates/prune/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ reth-stages = { path = "../stages", features = ["test-utils"] }

# misc

assert_matches = "1.5.0"
assert_matches = "1.5.0"

0 comments on commit bd644cd

Please sign in to comment.