Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Oct 3, 2023
1 parent 9d0e897 commit 7268a77
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 75 deletions.
4 changes: 2 additions & 2 deletions crates/consensus/beacon/src/engine/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use reth_interfaces::{
test_utils::{NoopFullBlockClient, TestConsensus},
};
use reth_payload_builder::test_utils::spawn_test_payload_service;
use reth_primitives::{BlockNumber, ChainSpec, PruneModes, B256, MAINNET, U256};
use reth_primitives::{BlockNumber, ChainSpec, PruneModes, B256, U256};
use reth_provider::{
providers::BlockchainProvider, test_utils::TestExecutorFactory, BlockExecutor,
BundleStateWithReceipts, ExecutorFactory, ProviderFactory, PrunableBlockExecutor,
Expand Down Expand Up @@ -520,7 +520,7 @@ where
self.base_config.chain_spec.clone(),
5,
PruneModes::none(),
MAINNET.prune_delete_limit,
self.base_config.chain_spec.prune_delete_limit,
watch::channel(None).1,
);

Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ pub use net::{
};
pub use peer::{PeerId, WithPeerId};
pub use prune::{
PruneCheckpoint, PruneMode, PruneModes, PrunePart, PrunePartError, ReceiptsLogPruneConfig,
MINIMUM_PRUNING_DISTANCE,
PruneCheckpoint, PruneMode, PruneModes, PrunePart, PrunePartError, PruneProgress,
ReceiptsLogPruneConfig, MINIMUM_PRUNING_DISTANCE,
};
pub use receipt::{Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts};
pub use serde_helper::JsonU256;
Expand Down
28 changes: 28 additions & 0 deletions crates/primitives/src/prune/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,31 @@ impl ReceiptsLogPruneConfig {
Ok(lowest.map(|lowest| lowest.max(pruned_block)))
}
}

/// Progress of pruning.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum PruneProgress {
/// There is more data to prune.
HasMoreData,
/// Pruning has been finished.
Finished,
}

impl PruneProgress {
/// Creates new [PruneProgress] from `done` boolean value.
///
/// If `done == true`, returns [PruneProgress::Finished], otherwise
/// [PruneProgress::HasMoreData] is returned.
pub fn from_done(done: bool) -> Self {
if done {
Self::Finished
} else {
Self::HasMoreData
}
}

/// Returns `true` if pruning has been finished.
pub fn is_finished(&self) -> bool {
matches!(self, Self::Finished)
}
}
4 changes: 2 additions & 2 deletions crates/prune/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reth_primitives::{BlockNumber, PrunePart};
use reth_primitives::{BlockNumber, PrunePart, PruneProgress};
use std::{collections::BTreeMap, time::Duration};

/// An event emitted by a [Pruner][crate::Pruner].
Expand All @@ -8,6 +8,6 @@ pub enum PrunerEvent {
Finished {
tip_block_number: BlockNumber,
elapsed: Duration,
parts: BTreeMap<PrunePart, (bool, usize)>,
parts: BTreeMap<PrunePart, (PruneProgress, usize)>,
},
}
Loading

0 comments on commit 7268a77

Please sign in to comment.