pub struct ContextVM<M, P: Patch> { /* private fields */ }
Expand description
A VM that executes using a context and block information.
Implementations
sourceimpl<M: Memory + Default, P: Patch> ContextVM<M, P>
impl<M: Memory + Default, P: Patch> ContextVM<M, P>
sourcepub fn new(context: Context, block: HeaderParams) -> Self
pub fn new(context: Context, block: HeaderParams) -> Self
Create a new VM using the given context, block header and patch.
sourcepub fn with_states(
context: Context,
block: HeaderParams,
account_state: AccountState<P::Account>,
blockhash_state: BlockhashState
) -> Self
pub fn with_states(
context: Context,
block: HeaderParams,
account_state: AccountState<P::Account>,
blockhash_state: BlockhashState
) -> Self
Create a new VM with the given account state and blockhash state.
sourcepub fn with_init<F: FnOnce(&mut ContextVM<M, P>)>(
context: Context,
block: HeaderParams,
account_state: AccountState<P::Account>,
blockhash_state: BlockhashState,
f: F
) -> Self
pub fn with_init<F: FnOnce(&mut ContextVM<M, P>)>(
context: Context,
block: HeaderParams,
account_state: AccountState<P::Account>,
blockhash_state: BlockhashState,
f: F
) -> Self
Create a new VM with customized initialization code.
sourcepub fn with_previous(
context: Context,
block: HeaderParams,
vm: &ContextVM<M, P>
) -> Self
pub fn with_previous(
context: Context,
block: HeaderParams,
vm: &ContextVM<M, P>
) -> Self
Create a new VM with the result of the previous VM. This is usually used by transaction for chainning them.
sourcepub fn current_state(&self) -> &State<M, P>
pub fn current_state(&self) -> &State<M, P>
Returns the current state of the VM.
sourcepub fn current_machine(&self) -> &Machine<M, P>
pub fn current_machine(&self) -> &Machine<M, P>
Returns the current runtime machine.
sourcepub fn add_context_history_hook<F: 'static + Fn(&Context)>(&mut self, f: F)
pub fn add_context_history_hook<F: 'static + Fn(&Context)>(&mut self, f: F)
Add a new context history hook.
Trait Implementations
sourceimpl<M: Memory + Default, P: Patch> VM for ContextVM<M, P>
impl<M: Memory + Default, P: Patch> VM for ContextVM<M, P>
sourcefn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
fn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
Commit an account information to this VM. This should only
be used when receiving
RequireError
. Read moresourcefn commit_blockhash(
&mut self,
number: U256,
hash: H256
) -> Result<(), CommitError>
fn commit_blockhash(
&mut self,
number: U256,
hash: H256
) -> Result<(), CommitError>
Commit a block hash to this VM. This should only be used when
receiving
RequireError
. Read moresourcefn peek(&self) -> Option<Instruction>
fn peek(&self) -> Option<Instruction>
Read the next instruction to be executed.
sourcefn peek_opcode(&self) -> Option<Opcode>
fn peek_opcode(&self) -> Option<Opcode>
Read the next opcode to be executed.
sourcefn step(&mut self) -> Result<(), RequireError>
fn step(&mut self) -> Result<(), RequireError>
Run one instruction and return. If it succeeds, VM status can
still be
Running
. If the call stack has more than one items,
this will only executes the last items’ one single
instruction. Read moresourcefn fire(&mut self) -> Result<(), RequireError>
fn fire(&mut self) -> Result<(), RequireError>
Run instructions until it reaches a
RequireError
or
exits. If this function succeeds, the VM status can only be
either ExitedOk
or ExitedErr
. Read moresourcefn accounts(&self) -> Values<'_, Address, AccountChange>
fn accounts(&self) -> Values<'_, Address, AccountChange>
Returns the changed or committed accounts information up to
current execution status. Read more
sourcefn used_addresses(&self) -> Set<Address>
fn used_addresses(&self) -> Set<Address>
Returns all fetched or modified addresses.
sourcefn out(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
fn out(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Returns the out value, if any.
sourcefn available_gas(&self) -> Gas
fn available_gas(&self) -> Gas
Returns the available gas of this VM.
sourcefn refunded_gas(&self) -> Gas
fn refunded_gas(&self) -> Gas
Returns the refunded gas of this VM.
sourcefn logs(&self) -> &[Log]
fn logs(&self) -> &[Log]
Returns logs to be appended to the current block if the user
decided to accept the running status of this VM. Read more
Auto Trait Implementations
impl<M, P> !RefUnwindSafe for ContextVM<M, P>
impl<M, P> !Send for ContextVM<M, P>
impl<M, P> !Sync for ContextVM<M, P>
impl<M, P> Unpin for ContextVM<M, P>where
M: Unpin,
<P as Patch>::Account: Unpin,
impl<M, P> !UnwindSafe for ContextVM<M, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more