diff --git a/Cargo.toml b/Cargo.toml index 56412e6..7aa4abc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ exclude = [".github/"] [workspace.lints.rust] type_alias_bounds = "allow" +unreachable_pub = "warn" [workspace.lints.clippy] tabs_in_doc_comments = "allow" diff --git a/examples/custom-bundle-type.rs b/examples/custom-bundle-type.rs index d4cf55c..888a511 100644 --- a/examples/custom-bundle-type.rs +++ b/examples/custom-bundle-type.rs @@ -131,7 +131,7 @@ struct CustomBundleType { } impl CustomBundleType { - pub fn with_min_profit(min_profit: U256) -> Self { + fn with_min_profit(min_profit: U256) -> Self { Self { txs: Vec::new(), reverting_txs: Vec::new(), diff --git a/src/pipelines/events.rs b/src/pipelines/events.rs index 19c1b0e..1dbc11c 100644 --- a/src/pipelines/events.rs +++ b/src/pipelines/events.rs @@ -13,7 +13,7 @@ use { /// - In a pipeline with nested pipelines, the top-level pipline's event bus is /// responsible for handling all events of all contained pipelines and steps. #[derive(Default, Debug)] -pub struct EventsBus { +pub(super) struct EventsBus { publishers: DashMap>>, phantom: PhantomData

, } @@ -21,7 +21,7 @@ pub struct EventsBus { impl EventsBus

{ /// Publishes an event of type `E` to all current subscribers. /// Each subscriber will receive a clone of the event. - pub fn publish(&self, event: E) + pub(super) fn publish(&self, event: E) where E: Clone + Any + Send + Sync + 'static, { @@ -29,7 +29,9 @@ impl EventsBus

{ } /// Returns a stream that yields events of type `E`. - pub fn subscribe(&self) -> impl Stream + Send + Sync + 'static + pub(super) fn subscribe( + &self, + ) -> impl Stream + Send + Sync + 'static where E: Clone + Any + Send + Sync + 'static, { @@ -63,7 +65,7 @@ impl EventsBus

{ } /// System events emitted by the pipeline itself. -pub mod system_events { +pub(super) mod system_events { use { super::*, derive_more::{Deref, From, Into}, diff --git a/src/pipelines/exec/mod.rs b/src/pipelines/exec/mod.rs index 4525c0b..c5519f6 100644 --- a/src/pipelines/exec/mod.rs +++ b/src/pipelines/exec/mod.rs @@ -64,7 +64,7 @@ impl> PipelineExecutor { /// Begins the execution of a pipeline for a new block/payload job. - pub fn run( + pub(super) fn run( pipeline: Arc>, block: BlockContext

, service: Arc>, @@ -114,7 +114,7 @@ impl> } /// Returns the payload id for which we are building a payload. - pub fn payload_id(&self) -> PayloadId { + pub(super) fn payload_id(&self) -> PayloadId { self.block.payload_id() } } diff --git a/src/pipelines/exec/navi.rs b/src/pipelines/exec/navi.rs index c49d4c1..14ab406 100644 --- a/src/pipelines/exec/navi.rs +++ b/src/pipelines/exec/navi.rs @@ -34,7 +34,7 @@ impl StepPath { /// If the step path points at a nested pipeline, this method will create a /// navigator that points to the first executable step starting from the /// nested pipeline. - pub fn navigator<'a, P: Platform>( + pub(crate) fn navigator<'a, P: Platform>( &self, root: &'a Pipeline

, ) -> Option> { @@ -67,7 +67,7 @@ impl StepPath { /// /// When this path points to an item, this value is the number of pipelines /// that contain the item starting from the top-level pipeline. - pub fn depth(&self) -> usize { + pub(crate) fn depth(&self) -> usize { self.0.len() } @@ -75,17 +75,17 @@ impl StepPath { /// This means that this path is inside a pipeline that has no parents. /// /// In other words, it checks if the path is a single element path. - pub fn is_toplevel(&self) -> bool { + pub(crate) fn is_toplevel(&self) -> bool { self.depth() == 1 } /// Returns `true` the the path is pointing to a prologue of a pipeline. - pub fn is_prologue(&self) -> bool { + pub(crate) fn is_prologue(&self) -> bool { self.leaf() == PROLOGUE_INDEX } /// Returns `true` if the path is pointing to an epilogue of a pipeline. - pub fn is_epilogue(&self) -> bool { + pub(crate) fn is_epilogue(&self) -> bool { self.leaf() == EPILOGUE_INDEX } } @@ -324,7 +324,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// deeper into the nested pipeline to find the first executable item. /// /// In empty pipelines, this will return None. - pub fn entrypoint(pipeline: &'a Pipeline

) -> Option { + pub(crate) fn entrypoint(pipeline: &'a Pipeline

) -> Option { if pipeline.is_empty() { return None; } @@ -351,7 +351,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// Returns a reference to the instance of the step that this path is /// currently pointing to. - pub fn instance(&self) -> &Arc> { + pub(crate) fn instance(&self) -> &Arc> { let step_index = self.0.leaf(); let enclosing_pipeline = self.pipeline(); @@ -380,7 +380,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// Returns a reference to the immediate enclosing pipeline that contains the /// current step. - pub fn pipeline(&self) -> &'a Pipeline

{ + pub(crate) fn pipeline(&self) -> &'a Pipeline

{ self.1.last().expect( "StepNavigator should always have at least one enclosing pipeline", ) @@ -388,7 +388,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// Returns a reference to the top-level pipeline that contains the /// current step. - pub fn root_pipeline(&self) -> &'a Pipeline

{ + pub(crate) fn root_pipeline(&self) -> &'a Pipeline

{ self.1.first().expect( "StepNavigator should always have at least one enclosing pipeline", ) @@ -398,7 +398,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// step's execution returns `ControlFlow::Ok`. /// /// Returns `None` if there are no more steps to execute in the pipeline. - pub fn next_ok(self) -> Option { + pub(crate) fn next_ok(self) -> Option { if self.is_epilogue() { // the loop is over. return self.next_in_parent(); @@ -447,7 +447,7 @@ impl<'a, P: Platform> StepNavigator<'a, P> { /// step's execution returns `ControlFlow::Break`. /// /// Returns `None` if there are no more steps to execute in the pipeline. - pub fn next_break(self) -> Option { + pub(crate) fn next_break(self) -> Option { if self.is_epilogue() { // the loop is over. return self.next_in_parent(); diff --git a/src/pipelines/exec/scope.rs b/src/pipelines/exec/scope.rs index 965e394..185d773 100644 --- a/src/pipelines/exec/scope.rs +++ b/src/pipelines/exec/scope.rs @@ -63,14 +63,17 @@ use { /// Scopes manage: /// - The metrics name for each pipeline and its nested pipelines /// - Limits calculation and renewal for pipeline steps. -pub struct RootScope { +pub(crate) struct RootScope { root: RwLock>, current: RefCell, } impl RootScope

{ /// Initialize all scopes in a given top-level pipeline. - pub fn new(pipeline: &Pipeline

, init_checkpoint: &Checkpoint

) -> Self { + pub(crate) fn new( + pipeline: &Pipeline

, + init_checkpoint: &Checkpoint

, + ) -> Self { let current = RefCell::new(StepPath::empty()); let root = Scope::rooted_at(pipeline, init_checkpoint); let root = RwLock::new(root); @@ -79,7 +82,7 @@ impl RootScope

{ } /// Given a path to a step in the pipeline, returns its current limits. - pub fn limits_of(&self, step_path: &StepPath) -> Option { + pub(crate) fn limits_of(&self, step_path: &StepPath) -> Option { self .root .read() @@ -88,7 +91,7 @@ impl RootScope

{ } /// Returns the instant when the scope was last entered. - pub fn entered_at(&self, step_path: &StepPath) -> Option { + pub(crate) fn entered_at(&self, step_path: &StepPath) -> Option { self .root .read() @@ -100,7 +103,7 @@ impl RootScope

{ /// It detects if the next step is in a different scope and enters and leaves /// scopes accordingly. This will leave and enter all intermediate scopes /// between the previous and next steps. - pub fn switch_context( + pub(crate) fn switch_context( &self, next_step: &StepPath, checkpoint: &Checkpoint

, @@ -132,18 +135,18 @@ impl RootScope

{ } } - pub fn enter(&self, checkpoint: &Checkpoint

) { + pub(crate) fn enter(&self, checkpoint: &Checkpoint

) { let mut root = self.root.write(); let limits = root.limits; root.enter(checkpoint, &limits); } - pub fn leave(&self) { + pub(crate) fn leave(&self) { let mut root = self.root.write(); root.leave(); } - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.root.read().is_active() } } @@ -165,7 +168,7 @@ fn scope_of(step: &StepPath) -> StepPath { /// execution. All steps in a pipeline run within the scopes of the pipelines /// that contain it. When a scope is active, then all its parent scopes are /// active as well. -pub struct Scope { +pub(crate) struct Scope { limits: Limits, metrics: Metrics, limits_factory: Option>>, @@ -178,23 +181,23 @@ pub struct Scope { impl Scope

{ /// When a scope is active it means that one of its steps (or in its nested /// scopes) is currently being executed, - pub const fn is_active(&self) -> bool { + pub(crate) const fn is_active(&self) -> bool { self.entered_at.is_some() } /// Returns the elapsed time since the scope was entered. /// This will only return a value if the scope is currently active. - pub fn elapsed(&self) -> Option { + pub(crate) fn elapsed(&self) -> Option { self.entered_at.map(|start| start.elapsed()) } /// Returns when the scope was entered most recently. - pub fn started_at(&self) -> Option { + pub(crate) fn started_at(&self) -> Option { self.entered_at } /// Returns the payload limits for steps running within the current scope. - pub const fn limits(&self) -> &Limits { + pub(crate) const fn limits(&self) -> &Limits { &self.limits } } @@ -353,7 +356,7 @@ unsafe impl Send for Scope

{} unsafe impl Sync for Scope

{} #[derive(MetricsSet)] -pub struct Metrics { +pub(crate) struct Metrics { /// Histogram of the number of iterations. pub iter_count_histogram: Histogram, diff --git a/src/pipelines/iter.rs b/src/pipelines/iter.rs index 84286db..7fb950d 100644 --- a/src/pipelines/iter.rs +++ b/src/pipelines/iter.rs @@ -15,7 +15,7 @@ struct Frame<'a, P: Platform> { } impl<'a, P: Platform> StepPathIter<'a, P> { - pub fn new(pipeline: &'a Pipeline

) -> Self { + pub(crate) fn new(pipeline: &'a Pipeline

) -> Self { Self { stack: vec![Frame { pipeline, diff --git a/src/pipelines/job.rs b/src/pipelines/job.rs index 4661306..867987a 100644 --- a/src/pipelines/job.rs +++ b/src/pipelines/job.rs @@ -31,7 +31,7 @@ use { /// This is a long-running job that will be polled by the CL node until it is /// resolved. The job future must resolve within 1 second from the moment /// [`PayloadJob::resolve_kind`] is called with [`PaylodKind::Earliest`]. -pub struct PayloadJob +pub(super) struct PayloadJob where P: Platform, Provider: traits::ProviderBounds

, @@ -45,7 +45,7 @@ where P: Platform, Provider: traits::ProviderBounds

, { - pub fn new( + pub(super) fn new( pipeline: &Arc>, block: BlockContext

, service: &Arc>, @@ -143,7 +143,7 @@ where /// This future wraps the `PipelineExecutor` and is used to poll the /// internal executor of the pipeline. Once this future is resolved, it /// can be polled again and will return copie of the resolved payload. -pub struct ExecutorFuture +pub(super) struct ExecutorFuture where P: Platform, Provider: traits::ProviderBounds

, @@ -175,7 +175,7 @@ where P: Platform, Provider: traits::ProviderBounds

, { - pub fn new(executor: PipelineExecutor) -> Self { + pub(super) fn new(executor: PipelineExecutor) -> Self { Self { started_at: Instant::now(), payload_id: executor.payload_id(), diff --git a/src/pipelines/limits.rs b/src/pipelines/limits.rs index 9cb8b6e..421b5bb 100644 --- a/src/pipelines/limits.rs +++ b/src/pipelines/limits.rs @@ -317,38 +317,38 @@ mod tests { impl TestStep { #[allow(dead_code)] - pub fn break_after(self, iterations: u32) -> Self { + fn break_after(self, iterations: u32) -> Self { self.break_after.store(iterations, Ordering::Relaxed); self } - pub fn expect_gas_limit(mut self, gas_limit: u64) -> Self { + fn expect_gas_limit(mut self, gas_limit: u64) -> Self { self.expected_gas_limit = Some(gas_limit); self } - pub fn expect_deadline(mut self, deadline: Duration) -> Self { + fn expect_deadline(mut self, deadline: Duration) -> Self { self.expected_deadline = Some(deadline); self } - pub fn expect_minimum_iterations(mut self, iterations: u32) -> Self { + fn expect_minimum_iterations(mut self, iterations: u32) -> Self { self.minimum_iterations = Some(iterations); self } - pub fn expect_maximum_iterations(mut self, iterations: u32) -> Self { + fn expect_maximum_iterations(mut self, iterations: u32) -> Self { self.maximum_iterations = Some(iterations); self } - pub fn sleep_on_step(mut self, duration: Duration) -> Self { + fn sleep_on_step(mut self, duration: Duration) -> Self { self.sleep_on_step = Some(duration); self } #[track_caller] - pub fn must_run(mut self) -> Self { + fn must_run(mut self) -> Self { self.must_run = true; self } diff --git a/src/pipelines/macros/src/metrics/mod.rs b/src/pipelines/macros/src/metrics/mod.rs index 3ebbfbf..0cb18fa 100644 --- a/src/pipelines/macros/src/metrics/mod.rs +++ b/src/pipelines/macros/src/metrics/mod.rs @@ -1,6 +1,6 @@ mod set; -pub use set::metrics_set_derive; +pub(crate) use set::metrics_set_derive; fn rblib_path() -> proc_macro2::TokenStream { use { diff --git a/src/pipelines/macros/src/metrics/set.rs b/src/pipelines/macros/src/metrics/set.rs index f5d1516..9f42ec5 100644 --- a/src/pipelines/macros/src/metrics/set.rs +++ b/src/pipelines/macros/src/metrics/set.rs @@ -35,7 +35,7 @@ use { /// before registering. /// - Adds a simple Debug impl (non-exhaustive) similar to metrics-derive style. #[allow(clippy::too_many_lines)] -pub fn metrics_set_derive(input: TokenStream) -> TokenStream { +pub(crate) fn metrics_set_derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); let ident = &input.ident; diff --git a/src/pipelines/macros/src/variants.rs b/src/pipelines/macros/src/variants.rs index 92228ac..5e8924c 100644 --- a/src/pipelines/macros/src/variants.rs +++ b/src/pipelines/macros/src/variants.rs @@ -13,7 +13,7 @@ use { /// ``` /// /// This will generate implementations for tuples of size 1 through 10. -pub fn impl_into_pipeline_steps(input: TokenStream) -> TokenStream { +pub(crate) fn impl_into_pipeline_steps(input: TokenStream) -> TokenStream { let count = parse_macro_input!(input as LitInt); let count_value = count .base10_parse::() diff --git a/src/pipelines/metrics.rs b/src/pipelines/metrics.rs index ab434fc..b523d92 100644 --- a/src/pipelines/metrics.rs +++ b/src/pipelines/metrics.rs @@ -8,7 +8,7 @@ use { }; #[derive(MetricsSet)] -pub struct Payload { +pub(super) struct Payload { /// Number of new payload jobs that have started. pub jobs_started: Counter, @@ -60,7 +60,7 @@ pub struct Payload { } impl Payload { - pub fn record_payload( + pub(super) fn record_payload( &self, payload: &types::BuiltPayload

, block: &BlockContext

, @@ -96,7 +96,7 @@ impl Payload { self.block_number.absolute(payload.block().number()); } - pub fn record_payload_job_attributes( + pub(super) fn record_payload_job_attributes( &self, attributes: &types::PayloadBuilderAttributes

, ) { diff --git a/src/pipelines/service.rs b/src/pipelines/service.rs index 4a613c5..e7a1468 100644 --- a/src/pipelines/service.rs +++ b/src/pipelines/service.rs @@ -30,7 +30,7 @@ pub(super) struct PipelineServiceBuilder { } impl PipelineServiceBuilder

{ - pub fn new(pipeline: Pipeline

) -> Self { + pub(super) fn new(pipeline: Pipeline

) -> Self { Self { pipeline } } } @@ -98,7 +98,7 @@ where /// There is one service context instance per reth node. This type gives /// individual jobs access to the node state, transaction pool and other /// runtime facilities that are managed by reth. -pub struct ServiceContext +pub(super) struct ServiceContext where Plat: Platform, Provider: traits::ProviderBounds, @@ -113,19 +113,21 @@ where Plat: Platform, Provider: traits::ProviderBounds, { - pub fn provider(&self) -> &Provider { + pub(super) fn provider(&self) -> &Provider { &self.provider } - pub const fn node_config(&self) -> &NodeConfig> { + pub(super) const fn node_config( + &self, + ) -> &NodeConfig> { &self.node_config } - pub const fn chain_spec(&self) -> &Arc> { + pub(super) const fn chain_spec(&self) -> &Arc> { &self.node_config().chain } - pub const fn metrics(&self) -> &metrics::Payload { + pub(super) const fn metrics(&self) -> &metrics::Payload { &self.metrics } } @@ -137,7 +139,7 @@ where /// The responsibility of this type is to respond to new payload requests when /// FCU calls come from the CL Node. Each FCU call will generate a new /// `PayloadID` on its side and will pass it to the `new_payload_job` method. -pub struct JobGenerator +pub(super) struct JobGenerator where Plat: Platform, Provider: traits::ProviderBounds, @@ -151,7 +153,7 @@ where Plat: Platform, Provider: traits::ProviderBounds, { - pub fn new( + pub(super) fn new( pipeline: Pipeline, service: ServiceContext, ) -> Self { diff --git a/src/pipelines/step/instance.rs b/src/pipelines/step/instance.rs index 8d9a8cf..25b2fd8 100644 --- a/src/pipelines/step/instance.rs +++ b/src/pipelines/step/instance.rs @@ -72,7 +72,7 @@ pub(crate) struct StepInstance { } impl StepInstance

{ - pub fn new>(step: S) -> Self { + pub(crate) fn new>(step: S) -> Self { let step: Arc = Arc::new(step); // This is the only place where we have access to the concrete step type @@ -148,7 +148,7 @@ impl StepInstance

{ /// This is invoked from places where we know the kind of the step and /// all other concrete types needed to execute the step and consume its /// output. - pub async fn step( + pub(crate) async fn step( &self, payload: Checkpoint

, ctx: StepContext

, @@ -179,7 +179,7 @@ impl StepInstance

{ } /// This is invoked once per pipeline run before any steps are executed. - pub async fn before_job( + pub(crate) async fn before_job( &self, ctx: StepContext

, ) -> Result<(), PayloadBuilderError> { @@ -212,7 +212,7 @@ impl StepInstance

{ } /// This is invoked once after the pipeline run has been completed. - pub async fn after_job( + pub(crate) async fn after_job( &self, ctx: StepContext

, result: Arc, PayloadBuilderError>>, @@ -261,12 +261,15 @@ impl StepInstance

{ /// This is invoked exactly once when a pipeline is instantiated as a payload /// builder service. - pub fn setup(&self, ctx: InitContext

) -> Result<(), PayloadBuilderError> { + pub(crate) fn setup( + &self, + ctx: InitContext

, + ) -> Result<(), PayloadBuilderError> { (self.setup_fn)(&self.instance, ctx) } /// Returns the name of the type that implements this step. - pub const fn name(&self) -> &str { + pub(crate) const fn name(&self) -> &str { self.name.pretty() } @@ -275,7 +278,7 @@ impl StepInstance

{ /// The input string is the metric name assigned to this step. This name is /// not known before the pipeline instance is fully built and converted into a /// service using [`PipelineServiceBuilder`]. It should be called only once. - pub fn init_metrics(&self, name: &str) { + pub(crate) fn init_metrics(&self, name: &str) { // Initialize the metrics name for this step. self.name.init_metrics(name); diff --git a/src/pipelines/step/metrics.rs b/src/pipelines/step/metrics.rs index 9b235f6..a7bf8ea 100644 --- a/src/pipelines/step/metrics.rs +++ b/src/pipelines/step/metrics.rs @@ -8,7 +8,7 @@ use { }; #[derive(MetricsSet)] -pub struct Metrics { +pub(super) struct Metrics { /// The total number of times this step's `step` method has been invoked. pub invoked_total: Counter, @@ -71,7 +71,7 @@ pub struct Metrics { /// Tracks metrics aggregates per job. Those counters get reset before each new /// payload job. #[derive(Default, Debug)] -pub struct PerJobCounters { +pub(super) struct PerJobCounters { /// The number of times this step was invoked during the last job. pub invoked: AtomicU32, @@ -82,27 +82,27 @@ pub struct PerJobCounters { impl PerJobCounters { /// Called at the end of a payload job - pub fn reset(&self) { + pub(super) fn reset(&self) { self.invoked.store(0, Ordering::Relaxed); self.exec_duration_micros.store(0, Ordering::Relaxed); } - pub fn increment_exec_time(&self, duration: Duration) { + pub(super) fn increment_exec_time(&self, duration: Duration) { #[expect(clippy::cast_possible_truncation)] self .exec_duration_micros .fetch_add(duration.as_micros() as u64, Ordering::Relaxed); } - pub fn increment_invocation(&self) { + pub(super) fn increment_invocation(&self) { self.invoked.fetch_add(1, Ordering::Relaxed); } - pub fn exec_duration(&self) -> Duration { + pub(super) fn exec_duration(&self) -> Duration { Duration::from_micros(self.exec_duration_micros.load(Ordering::Relaxed)) } - pub fn invoked_count(&self) -> u32 { + pub(super) fn invoked_count(&self) -> u32 { self.invoked.load(Ordering::Relaxed) } } diff --git a/src/pipelines/step/name.rs b/src/pipelines/step/name.rs index a6903e9..9682b6e 100644 --- a/src/pipelines/step/name.rs +++ b/src/pipelines/step/name.rs @@ -1,13 +1,13 @@ use {crate::prelude::*, core::any::type_name, std::sync::OnceLock}; #[derive(Debug, Clone)] -pub struct Name { +pub(super) struct Name { pretty: String, metrics: OnceLock, } impl Name { - pub fn new, P: Platform>() -> Self { + pub(super) fn new, P: Platform>() -> Self { Self { pretty: short_type_name(type_name::()), metrics: OnceLock::new(), @@ -17,7 +17,7 @@ impl Name { /// Returns a short type name of the step. /// /// Strips away all type paths and leaves only the last component. - pub const fn pretty(&self) -> &str { + pub(super) const fn pretty(&self) -> &str { self.pretty.as_str() } @@ -26,7 +26,7 @@ impl Name { /// # Panics /// This value can only be used only after initializing the metric name /// through `init_metric`. - pub fn metric(&self) -> &str { + pub(super) fn metric(&self) -> &str { self .metrics .get() @@ -42,7 +42,7 @@ impl Name { /// /// # Panics /// This function will panic if the metric name has already been initialized. - pub fn init_metrics(&self, name: impl Into) { + pub(super) fn init_metrics(&self, name: impl Into) { self .metrics .set(name.into()) @@ -50,7 +50,7 @@ impl Name { } /// Returns true if the metric name has been initialized. - pub fn has_metrics(&self) -> bool { + pub(super) fn has_metrics(&self) -> bool { self.metrics.get().is_some() } } diff --git a/src/platform/ethereum/pool.rs b/src/platform/ethereum/pool.rs index c50ed8c..105b64e 100644 --- a/src/platform/ethereum/pool.rs +++ b/src/platform/ethereum/pool.rs @@ -17,14 +17,14 @@ use { std::{collections::hash_map::Entry, sync::Arc}, }; -pub struct FixedTransactions { +pub(super) struct FixedTransactions { txs: Vec>>, senders: SenderIdentifiers, invalid: HashMap, } impl FixedTransactions

{ - pub fn new(txs: Vec>>) -> Self { + pub(super) fn new(txs: Vec>>) -> Self { // reverse because we want to pop from the end // in the iterator. let mut txs = txs; diff --git a/src/pool/host.rs b/src/pool/host.rs index 0a9ac8a..7da8761 100644 --- a/src/pool/host.rs +++ b/src/pool/host.rs @@ -27,7 +27,7 @@ use { /// - garbage collection of orders that have transactions that were included in /// a committed block. #[derive(Default)] -pub struct HostNode { +pub(super) struct HostNode { instances: OnceLock>, } @@ -36,7 +36,7 @@ impl HostNode

{ /// This binds the host Reth node to the order pool instance. /// This method should be called only once and will fail if the pool is /// already attached to a host node. - pub fn attach( + pub(super) fn attach( self: &Arc, system_pool: Arc, order_pool: Arc>, @@ -88,12 +88,12 @@ impl HostNode

{ /// Returns true if the host Reth node is attached to the `OrderPool`. /// Attachment is done by the `attach_pool` method during node components /// setup. - pub fn is_attached(&self) -> bool { + pub(super) fn is_attached(&self) -> bool { self.instances.get().is_some() } /// If attached, invokes the provided function with the current tip header. - pub fn map_tip_header(&self, op: F) -> Option + pub(super) fn map_tip_header(&self, op: F) -> Option where F: FnOnce(&SealedHeader>) -> R, { @@ -102,13 +102,13 @@ impl HostNode

{ /// If attached to a host node, this will return a reference to the reth /// native transaction pool. - pub fn system_pool(&self) -> Option<&impl traits::PoolBounds

> { + pub(super) fn system_pool(&self) -> Option<&impl traits::PoolBounds

> { self.instances.get().map(|i| &i.system_pool) } /// If attached to a host node, this will remove a transaction from the reth /// native transaction pool. - pub fn remove_transaction(&self, txhash: TxHash) { + pub(super) fn remove_transaction(&self, txhash: TxHash) { if let Some(pool) = self.instances.get().map(|i| &i.system_pool) { pool.remove_transactions(vec![txhash]); } @@ -145,7 +145,9 @@ impl HostNode

{ #[cfg(feature = "test-utils")] impl HostNode

{ - pub fn attach_to_test_node>( + pub(crate) fn attach_to_test_node< + C: crate::test_utils::ConsensusDriver

, + >( self: &Arc, node: &crate::test_utils::LocalNode, order_pool: OrderPool

, diff --git a/src/pool/mod.rs b/src/pool/mod.rs index 9a7e38a..f232ecb 100644 --- a/src/pool/mod.rs +++ b/src/pool/mod.rs @@ -173,7 +173,7 @@ struct OrderPoolInner { } impl OrderPoolInner

{ - pub fn outer(self: &Arc) -> OrderPool

{ + pub(crate) fn outer(self: &Arc) -> OrderPool

{ OrderPool { inner: Arc::clone(self), } @@ -187,4 +187,4 @@ impl From>> for OrderPool

{ } #[cfg(feature = "test-utils")] -pub use native::NativeTransactionPool; +pub(crate) use native::NativeTransactionPool; diff --git a/src/pool/native.rs b/src/pool/native.rs index bbf7f64..29f3620 100644 --- a/src/pool/native.rs +++ b/src/pool/native.rs @@ -27,7 +27,7 @@ use { /// /// It is unfortunate that Reth's `TransactionPool` trait is not dyn-safe, /// because it inherits from `Clone`, which forces us to wrap it here. -pub struct NativeTransactionPool { +pub(crate) struct NativeTransactionPool { vtable: TransactionPoolVTable

, } @@ -40,7 +40,7 @@ impl Clone for NativeTransactionPool

{ } impl NativeTransactionPool

{ - pub fn new>(pool: Arc) -> Self { + pub(crate) fn new>(pool: Arc) -> Self { let vtable = TransactionPoolVTable::new(pool); Self { vtable } } @@ -245,7 +245,7 @@ struct TransactionPoolVTable { impl TransactionPoolVTable

{ /// Creates a new vtable from a `TransactionPool` implementation #[allow(clippy::too_many_lines)] - pub fn new>(pool: Pool) -> Self { + pub(crate) fn new>(pool: Pool) -> Self { let self_ptr = Box::into_raw(Box::new(pool)) as *const u8; Self { diff --git a/src/pool/rpc.rs b/src/pool/rpc.rs index 5d0aefb..d15bd17 100644 --- a/src/pool/rpc.rs +++ b/src/pool/rpc.rs @@ -16,7 +16,7 @@ pub(super) struct BundleRpcApi { } impl BundleRpcApi

{ - pub fn new(pool: &OrderPool

) -> Self { + pub(super) fn new(pool: &OrderPool

) -> Self { Self { pool: pool.clone() } } } diff --git a/src/pool/select.rs b/src/pool/select.rs index a426c3b..50086f4 100644 --- a/src/pool/select.rs +++ b/src/pool/select.rs @@ -31,7 +31,7 @@ struct PoolsDemux<'o, P: Platform> { } impl<'o, P: Platform> PoolsDemux<'o, P> { - pub fn new( + pub(crate) fn new( system_pool: Option<&impl traits::PoolBounds

>, order_pool: impl Iterator> + 'o, ) -> Self { diff --git a/src/pool/setup.rs b/src/pool/setup.rs index 75771e6..c76f5a1 100644 --- a/src/pool/setup.rs +++ b/src/pool/setup.rs @@ -141,7 +141,10 @@ struct SystemPoolWrapper { } impl SystemPoolWrapper { - pub fn new(builder: Builder, order_pool: Arc>) -> Self + pub(crate) fn new( + builder: Builder, + order_pool: Arc>, + ) -> Self where Builder: PoolBuilderBounds, Node: FullNodeTypes>>, diff --git a/src/pool/step.rs b/src/pool/step.rs index 9700836..bca1645 100644 --- a/src/pool/step.rs +++ b/src/pool/step.rs @@ -341,7 +341,7 @@ impl<'a, P: Platform> Run<'a, P> { /// Tries to extend the current payload with the contents of the given order. /// If the order is skipped, the payload checkpoint remains unchanged. - pub fn try_include(&mut self, order: Order

) { + pub(crate) fn try_include(&mut self, order: Order

) { self.step.metrics.considered(&order); self.step.per_job.considered(&order); @@ -416,7 +416,7 @@ impl<'a, P: Platform> Run<'a, P> { )); } - pub fn end(self) -> ControlFlow

{ + pub(crate) fn end(self) -> ControlFlow

{ if self.step.break_on_limit && self.txs_included == 0 { ControlFlow::Break(self.payload) } else { @@ -512,7 +512,7 @@ struct Metrics { #[allow(clippy::cast_possible_truncation)] impl Metrics { - pub fn considered(&self, order: &Order

) { + pub(crate) fn considered(&self, order: &Order

) { self.orders_considered.increment(1); self .txs_considered @@ -526,7 +526,7 @@ impl Metrics { } } - pub fn skipped(&self, order: &Order

) { + pub(crate) fn skipped(&self, order: &Order

) { self.orders_skipped.increment(1); self .txs_skipped @@ -536,7 +536,7 @@ impl Metrics { } } - pub fn included(&self, checkpoint: &Checkpoint

) { + pub(crate) fn included(&self, checkpoint: &Checkpoint

) { self.orders_included.increment(1); self .txs_included @@ -558,7 +558,7 @@ impl Metrics { } } - pub fn record_per_job(&self, counters: &PerJobCounters) { + pub(crate) fn record_per_job(&self, counters: &PerJobCounters) { self .per_job_orders_considered .record(counters.orders_considered.load(Ordering::Relaxed)); @@ -594,7 +594,7 @@ struct PerJobCounters { #[allow(clippy::cast_possible_truncation)] impl PerJobCounters { - pub fn reset(&self) { + pub(crate) fn reset(&self) { self.orders_considered.store(0, Ordering::Relaxed); self.txs_considered.store(0, Ordering::Relaxed); self.bundles_considered.store(0, Ordering::Relaxed); @@ -604,7 +604,7 @@ impl PerJobCounters { self.bundles_included.store(0, Ordering::Relaxed); } - pub fn considered(&self, order: &Order

) { + pub(crate) fn considered(&self, order: &Order

) { self.orders_considered.fetch_add(1, Ordering::Relaxed); self @@ -616,7 +616,7 @@ impl PerJobCounters { } } - pub fn included(&self, checkpoint: &Checkpoint

) { + pub(crate) fn included(&self, checkpoint: &Checkpoint

) { self.orders_included.fetch_add(1, Ordering::Relaxed); self diff --git a/src/steps/ordering/mod.rs b/src/steps/ordering/mod.rs index 5f78ddb..b1f1451 100644 --- a/src/steps/ordering/mod.rs +++ b/src/steps/ordering/mod.rs @@ -181,7 +181,7 @@ impl<'a, P: Platform, S: OrderScore

> IntoIterator } impl<'a, P: Platform, S: OrderScore

> SortedOrders<'a, P, S> { - pub fn pop_best(&mut self) -> Option<&'a Checkpoint

> { + pub(crate) fn pop_best(&mut self) -> Option<&'a Checkpoint

> { let mut skip = 0; let (order, score) = 'order: loop { diff --git a/src/steps/revert.rs b/src/steps/revert.rs index b0c58b8..c499f00 100644 --- a/src/steps/revert.rs +++ b/src/steps/revert.rs @@ -192,31 +192,31 @@ struct PerJobCounters { impl PerJobCounters { /// Called at the end of a payload job - pub fn reset(&self) { + pub(crate) fn reset(&self) { self.txs_dropped.store(0, Ordering::Relaxed); self.gas_dropped.store(0, Ordering::Relaxed); } /// Increment the number of dropped transactions for this job. - pub fn inc_txs_dropped(&self, count: usize) { + pub(crate) fn inc_txs_dropped(&self, count: usize) { let count: u32 = count.try_into().expect("realistically impossible"); self.txs_dropped.fetch_add(count, Ordering::Relaxed); } - pub fn inc_gas_dropped(&self, amount: u64) { + pub(crate) fn inc_gas_dropped(&self, amount: u64) { self.gas_dropped.fetch_add(amount, Ordering::Relaxed); } - pub fn mark_dropped(&self, checkpoint: &Checkpoint

) { + pub(crate) fn mark_dropped(&self, checkpoint: &Checkpoint

) { self.inc_txs_dropped(checkpoint.transactions().len()); self.inc_gas_dropped(checkpoint.gas_used()); } - pub fn txs_dropped_count(&self) -> u32 { + pub(crate) fn txs_dropped_count(&self) -> u32 { self.txs_dropped.load(Ordering::Relaxed) } - pub fn gas_dropped_count(&self) -> u64 { + pub(crate) fn gas_dropped_count(&self) -> u64 { self.gas_dropped.load(Ordering::Relaxed) } } diff --git a/src/test_utils/node.rs b/src/test_utils/node.rs index 34e625a..4839af7 100644 --- a/src/test_utils/node.rs +++ b/src/test_utils/node.rs @@ -231,7 +231,7 @@ where } /// Returns a reference to the native transaction pool. - pub const fn pool(&self) -> &NativeTransactionPool

{ + pub(crate) const fn pool(&self) -> &NativeTransactionPool

{ &self.pool } diff --git a/src/test_utils/step.rs b/src/test_utils/step.rs index 5e199d0..91d29fd 100644 --- a/src/test_utils/step.rs +++ b/src/test_utils/step.rs @@ -16,7 +16,7 @@ use { macro_rules! fake_step { ($name:ident) => { #[derive(Debug, Default, Clone)] - pub struct $name; + pub(super) struct $name; impl $crate::prelude::Step

for $name { async fn step( self: std::sync::Arc, @@ -59,7 +59,7 @@ macro_rules! fake_step { ($name:ident, $state:ident) => { #[allow(dead_code)] #[derive(Debug, Clone)] - pub struct $name($state); + pub(super) struct $name($state); impl $crate::prelude::Step

for $name { async fn step( self: std::sync::Arc, @@ -277,7 +277,7 @@ struct PopulatePayload { } impl PopulatePayload

{ - pub fn new() -> (Self, UnboundedSender>) { + pub(crate) fn new() -> (Self, UnboundedSender>) { let (sender, receiver) = unbounded_channel(); ( Self { @@ -316,7 +316,7 @@ struct RecordOk { } impl RecordOk

{ - pub fn new() -> (Self, UnboundedReceiver>) { + pub(crate) fn new() -> (Self, UnboundedReceiver>) { let (sender, receiver) = unbounded_channel(); (Self { sender }, receiver) } @@ -339,7 +339,7 @@ struct RecordBreakAndFail { } impl RecordBreakAndFail

{ - pub fn new() -> ( + pub(crate) fn new() -> ( Self, UnboundedReceiver, UnboundedReceiver>,