Skip to content

Commit

Permalink
feat: add state_hook_sender fn on StateRootTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Jan 20, 2025
1 parent 390165a commit a2988b6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/engine/tree/src/tree/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ impl ProofSequencer {
}

/// A wrapper for the sender that signals completion when dropped
#[derive(Deref)]
pub(crate) struct StateHookSender<BPF: BlindedProviderFactory>(Sender<StateRootMessage<BPF>>);
#[derive(Deref, Debug)]
pub struct StateHookSender<BPF: BlindedProviderFactory>(Sender<StateRootMessage<BPF>>);

impl<BPF: BlindedProviderFactory> StateHookSender<BPF> {
pub(crate) const fn new(inner: Sender<StateRootMessage<BPF>>) -> Self {
Expand Down Expand Up @@ -325,9 +325,14 @@ where
StateRootHandle::new(rx)
}

/// Returns a [`StateHookSender`] that can be used to send state updates to this task.
pub fn state_hook_sender(&self) -> StateHookSender<BPF> {
StateHookSender::new(self.tx.clone())
}

/// Returns a state hook to be used to send state updates to this task.
pub fn state_hook(&self) -> impl OnStateHook {
let state_hook = StateHookSender::new(self.tx.clone());
let state_hook = self.state_hook_sender();

move |state: &EvmState| {
if let Err(error) = state_hook.send(StateRootMessage::StateUpdate(state.clone())) {
Expand Down

0 comments on commit a2988b6

Please sign in to comment.