Struct Engine

Source
pub struct Engine { /* private fields */ }
Expand description

The Engine task queue.

Tasks of a shared EngineTask variant are processed in FIFO order, providing synchronization guarantees for the L2 execution layer and other actors. A priority queue, ordered by EngineTask’s Ord implementation, is used to prioritize tasks executed by the Engine::drain method.

Because tasks are executed one at a time, they are considered to be atomic operations over the EngineState, and are given exclusive access to the engine state during execution.

Tasks within the queue are also considered fallible. If they fail with a temporary error, they are not popped from the queue, the error is returned, and they are retried on the next call to Engine::drain.

Implementations§

Source§

impl Engine

Source

pub fn new( initial_state: EngineState, state_sender: Sender<EngineState>, task_queue_length: Sender<usize>, ) -> Self

Creates a new Engine with an empty task queue and the passed initial EngineState.

Source

pub const fn state(&self) -> &EngineState

Returns a reference to the inner EngineState.

Source

pub fn state_subscribe(&self) -> Receiver<EngineState>

Returns a receiver that can be used to listen to engine state updates.

Source

pub fn queue_length_subscribe(&self) -> Receiver<usize>

Returns a receiver that can be used to listen to engine queue length updates.

Source

pub fn enqueue(&mut self, task: EngineTask)

Enqueues a new EngineTask for execution. Updates the queue length and notifies listeners of the change.

Source

pub async fn reset( &mut self, client: Arc<EngineClient>, config: Arc<RollupConfig>, ) -> Result<(L2BlockInfo, BlockInfo, SystemConfig), EngineResetError>

Resets the engine by finding a plausible sync starting point via find_starting_forkchoice. The state will be updated to the starting point, and a forkchoice update will be enqueued in order to reorg the execution layer.

Source

pub fn clear(&mut self)

Clears the task queue.

Source

pub async fn drain(&mut self) -> Result<(), EngineTaskErrors>

Attempts to drain the queue by executing all EngineTasks in-order. If any task returns an error along the way, it is not popped from the queue (in case it must be retried) and the error is returned.

Trait Implementations§

Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl !UnwindSafe for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,