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:Runtimefor production,MockRuntimefor testing)S: The state storage type (default:Storagefor disk-based, can useMockStateStoragefor in-memory)
Fields§
§state_store: StateStore<S>Implementations§
Source§impl Executor<MockRuntime, Storage>
Executor with MockRuntime using disk-based state storage (for backward compatibility)
impl Executor<MockRuntime, Storage>
Executor with MockRuntime using disk-based state storage (for backward compatibility)
Sourcepub async fn new_mock(
identifier: &str,
op_sender: Option<Sender<(Transaction, Sender<Result<OpEnum, OpRequestError>>)>>,
op_manager: Option<Arc<OpManager>>,
) -> Result<Self>
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)
impl Executor<MockRuntime, MockStateStorage>
Executor with MockRuntime using fully in-memory storage (for deterministic simulation)
Sourcepub 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>
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 operationsop_manager- Optional reference to the operation manager
Source§impl<S> Executor<MockRuntime, S>
Common methods for MockRuntime executors (works with any storage type)
impl<S> Executor<MockRuntime, S>
Common methods for MockRuntime executors (works with any storage type)
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>
impl Executor<MockWasmRuntime, MockStateStorage>
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>
impl Executor<Runtime>
Sourcepub async fn from_config_local(config: Arc<Config>) -> Result<Self>
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.
pub async fn preload( &mut self, cli_id: ClientId, contract: ContractContainer, state: WrappedState, related_contracts: RelatedContracts<'static>, )
pub async fn handle_request( &mut self, id: ClientId, req: ClientRequest<'_>, updates: Option<Sender<Result<HostResponse, WsClientError>>>, ) -> Result<HostResponse, ExecutorError>
Sourcepub async fn contract_requests(
&mut self,
req: ContractRequest<'_>,
cli_id: ClientId,
updates: Option<Sender<Result<HostResponse, WsClientError>>>,
) -> Result<HostResponse, ExecutorError>
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.
pub fn delegate_request( &mut self, req: DelegateRequest<'_>, origin_contract: Option<&ContractInstanceId>, caller_delegate: Option<&DelegateKey>, ) -> Result<HostResponse, ExecutorError>
Auto Trait Implementations§
impl<R, S> Freeze for Executor<R, S>
impl<R = Runtime, S = ReDb> !RefUnwindSafe for Executor<R, S>
impl<R, S> Send for Executor<R, S>
impl<R, S> Sync for Executor<R, S>
impl<R, S> Unpin for Executor<R, S>
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> 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