Skip to main content

Executor

Struct Executor 

Source
pub struct Executor<R = Runtime, S: StateStorage = Storage> {
    pub state_store: StateStore<S>,
    /* private fields */
}
Expand description

Consumers of the executor are required to poll for new changes in order to be notified of changes or can alternatively use the notification channel.

The type parameters are:

  • R: The runtime type (default: Runtime for production, MockRuntime for testing)
  • S: The state storage type (default: Storage for disk-based, can use MockStateStorage for in-memory)

Fields§

§state_store: StateStore<S>

Implementations§

Source§

impl Executor<MockRuntime, Storage>

Executor with MockRuntime using disk-based state storage (for backward compatibility)

Source

pub async fn new_mock( identifier: &str, op_sender: Option<Sender<(Transaction, Sender<Result<OpEnum, OpRequestError>>)>>, op_manager: Option<Arc<OpManager>>, ) -> Result<Self>

Create a mock executor with disk-based state storage.

Contract code is stored in memory (InMemoryContractStore) for determinism, but state is stored on disk (SQLite). For fully in-memory storage, use new_mock_in_memory.

Source§

impl Executor<MockRuntime, MockStateStorage>

Executor with MockRuntime using fully in-memory storage (for deterministic simulation)

Source

pub async fn new_mock_in_memory( _identifier: &str, shared_storage: MockStateStorage, op_sender: Option<Sender<(Transaction, Sender<Result<OpEnum, OpRequestError>>)>>, op_manager: Option<Arc<OpManager>>, ) -> Result<Self>

Create a mock executor with fully in-memory storage.

This is designed for deterministic simulation testing where:

  • Both contract code and state are stored in memory
  • No disk I/O or background threads (file watchers, compaction)
  • State persists across node crash/restart (same MockStateStorage instance)
  • State can be inspected/verified through MockStateStorage methods
§Arguments
  • _identifier - Unused (kept for API compatibility)
  • shared_storage - A MockStateStorage instance (clone it to share across restarts)
  • op_sender - Optional channel for network operations
  • op_manager - Optional reference to the operation manager
Source§

impl<S> Executor<MockRuntime, S>
where S: StateStorage + Send + Sync + 'static, <S as StateStorage>::Error: Into<Error>,

Common methods for MockRuntime executors (works with any storage type)

Source

pub async fn handle_request( &mut self, _id: ClientId, _req: ClientRequest<'_>, _updates: Option<Sender<Result<HostResponse, WsClientError>>>, ) -> Result<HostResponse, ExecutorError>

Source§

impl Executor<MockWasmRuntime, MockStateStorage>

Source

pub async fn new_mock_wasm( _identifier: &str, shared_storage: MockStateStorage, contract_store: Option<InMemoryContractStore>, op_sender: Option<Sender<(Transaction, Sender<Result<OpEnum, OpRequestError>>)>>, op_manager: Option<Arc<OpManager>>, ) -> Result<Self>

Source§

impl Executor<Runtime>

Source

pub async fn from_config_local(config: Arc<Config>) -> Result<Self>

Create an Executor for local-only mode (no network operations). Use this from the binary for local mode execution.

Source

pub async fn preload( &mut self, cli_id: ClientId, contract: ContractContainer, state: WrappedState, related_contracts: RelatedContracts<'static>, )

Source

pub async fn handle_request( &mut self, id: ClientId, req: ClientRequest<'_>, updates: Option<Sender<Result<HostResponse, WsClientError>>>, ) -> Result<HostResponse, ExecutorError>

Source

pub async fn contract_requests( &mut self, req: ContractRequest<'_>, cli_id: ClientId, updates: Option<Sender<Result<HostResponse, WsClientError>>>, ) -> Result<HostResponse, ExecutorError>

Respond to requests made through any API’s from client applications in local mode.

Source

pub fn delegate_request( &mut self, req: DelegateRequest<'_>, origin_contract: Option<&ContractInstanceId>, caller_delegate: Option<&DelegateKey>, ) -> Result<HostResponse, ExecutorError>

Source§

impl<R, S> Executor<R, S>
where S: StateStorage + Send + 'static, <S as StateStorage>::Error: Into<Error>,

Source

pub fn test_data_dir(identifier: &str) -> PathBuf

Source

pub fn get_subscription_info(&self) -> Vec<SubscriptionInfo>

Auto Trait Implementations§

§

impl<R, S> Freeze for Executor<R, S>
where R: Freeze, S: Freeze,

§

impl<R = Runtime, S = ReDb> !RefUnwindSafe for Executor<R, S>

§

impl<R, S> Send for Executor<R, S>
where R: Send, S: Send,

§

impl<R, S> Sync for Executor<R, S>
where R: Sync, S: Sync,

§

impl<R, S> Unpin for Executor<R, S>
where R: Unpin, S: Unpin,

§

impl<R, S> UnsafeUnpin for Executor<R, S>
where R: UnsafeUnpin, S: UnsafeUnpin,

§

impl<R = Runtime, S = ReDb> !UnwindSafe for Executor<R, S>

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,