pub trait SyncHost: BaseHost {
// Required methods
fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>;
fn on_event(
&mut self,
process: &ProcessState<'_>,
) -> Result<Vec<AdviceMutation>, EventError>;
}
Expand description
Defines an interface by which the VM can interact with the host.
There are four main categories of interactions between the VM and the host:
- accessing the advice provider,
- getting a library’s MAST forest,
- handling VM events (which can mutate the process’ advice provider), and
- handling debug and trace events.
Required Methods§
Sourcefn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>
fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>
Returns MAST forest corresponding to the specified digest, or None if the MAST forest for this digest could not be found in this host.
Sourcefn on_event(
&mut self,
process: &ProcessState<'_>,
) -> Result<Vec<AdviceMutation>, EventError>
fn on_event( &mut self, process: &ProcessState<'_>, ) -> Result<Vec<AdviceMutation>, EventError>
Invoked when the VM encounters an EMIT
operation.
The event ID is available at the top of the stack (position 0) when this handler is called. This allows the handler to access both the event ID and any additional context data that may have been pushed onto the stack prior to the emit operation.