Struct sputnikvm::TransactionVM
source · pub struct TransactionVM<M, P: Patch>(_);
Expand description
A VM that executes using a transaction and block information.
Implementations
sourceimpl<M: Memory + Default, P: Patch> TransactionVM<M, P>
impl<M: Memory + Default, P: Patch> TransactionVM<M, P>
sourcepub fn new_untrusted(
transaction: UntrustedTransaction,
block: HeaderParams
) -> Result<Self, PreExecutionError>
pub fn new_untrusted(
transaction: UntrustedTransaction,
block: HeaderParams
) -> Result<Self, PreExecutionError>
Create a VM from an untrusted transaction. It can be any transaction and the VM will return an error if it has errors.
sourcepub fn new(transaction: ValidTransaction, block: HeaderParams) -> Self
pub fn new(transaction: ValidTransaction, block: HeaderParams) -> Self
Create a new VM using the given transaction, block header and patch. This VM runs at the transaction level.
sourcepub fn with_previous(
transaction: ValidTransaction,
block: HeaderParams,
vm: &TransactionVM<M, P>
) -> Self
pub fn with_previous(
transaction: ValidTransaction,
block: HeaderParams,
vm: &TransactionVM<M, P>
) -> Self
Create a new VM with the result of the previous VM. This is usually used by transaction for chaining them.
sourcepub fn current_state(&self) -> Option<&State<M, P>>
pub fn current_state(&self) -> Option<&State<M, P>>
Returns the current state of the VM.
sourcepub fn current_machine(&self) -> Option<&Machine<M, P>>
pub fn current_machine(&self) -> Option<&Machine<M, P>>
Returns the current runtime machine.
Trait Implementations
sourceimpl<M: Memory + Default, P: Patch> VM for TransactionVM<M, P>
impl<M: Memory + Default, P: Patch> VM for TransactionVM<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 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
sourcefn removed(&self) -> &[Address]
fn removed(&self) -> &[Address]
Returns all removed account addresses as for current VM execution.
Auto Trait Implementations
impl<M, P> !RefUnwindSafe for TransactionVM<M, P>
impl<M, P> !Send for TransactionVM<M, P>
impl<M, P> !Sync for TransactionVM<M, P>
impl<M, P> Unpin for TransactionVM<M, P>where
M: Unpin,
<P as Patch>::Account: Unpin,
impl<M, P> !UnwindSafe for TransactionVM<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