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
impl Engine
Sourcepub fn new(
initial_state: EngineState,
state_sender: Sender<EngineState>,
task_queue_length: Sender<usize>,
) -> Self
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.
Sourcepub const fn state(&self) -> &EngineState
pub const fn state(&self) -> &EngineState
Returns a reference to the inner EngineState.
Sourcepub fn state_subscribe(&self) -> Receiver<EngineState>
pub fn state_subscribe(&self) -> Receiver<EngineState>
Returns a receiver that can be used to listen to engine state updates.
Sourcepub fn queue_length_subscribe(&self) -> Receiver<usize>
pub fn queue_length_subscribe(&self) -> Receiver<usize>
Returns a receiver that can be used to listen to engine queue length updates.
Sourcepub fn enqueue(&mut self, task: EngineTask)
pub fn enqueue(&mut self, task: EngineTask)
Enqueues a new EngineTask for execution.
Updates the queue length and notifies listeners of the change.
Sourcepub async fn reset(
&mut self,
client: Arc<EngineClient>,
config: Arc<RollupConfig>,
) -> Result<(L2BlockInfo, BlockInfo, SystemConfig), EngineResetError>
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.
Sourcepub async fn drain(&mut self) -> Result<(), EngineTaskErrors>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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