pub struct Transactor<S, Tx> { /* private fields */ }
Expand description

State machine to execute transactions and provide runtime entities on demand.

Builder pattern for Interpreter. Follows the recommended Non-consuming builder.

Based on https://doc.rust-lang.org/1.5.0/style/ownership/builders.html#non-consuming-builders-preferred

Implementations§

source§

impl<'a, S, Tx> Transactor<S, Tx>where Tx: ExecutableTransaction,

source

pub fn new(storage: S, params: ConsensusParameters, gas_costs: GasCosts) -> Self

Transactor constructor

source

pub fn state_transition(&'a self) -> Option<StateTransitionRef<'a, Tx>>

State transition representation after the execution of a transaction.

Will be None if the last transaction resulted in a VM panic, or if no transaction was executed.

source

pub fn to_owned_state_transition(&self) -> Option<StateTransition<Tx>>

State transition representation after the execution of a transaction.

Will be None if the last transaction resulted in a VM panic, or if no transaction was executed.

source

pub const fn error(&self) -> Option<&InterpreterError>

Interpreter error representation after the execution of a transaction.

Follows the same criteria as Self::state_transition to return None.

Will be None if the last transaction resulted successful, or if no transaction was executed.

source

pub const fn is_success(&self) -> bool

Returns true if last transaction execution was successful

source

pub const fn is_error(&self) -> bool

Returns true if last transaction execution was erroneous

source

pub fn result(&'a self) -> Result<StateTransitionRef<'a, Tx>, &InterpreterError>

Result representation of the last executed transaction.

Will return None if no transaction was executed.

source

pub fn interpreter(self) -> Interpreter<S, Tx>

Convert this transaction into the underlying VM instance.

This isn’t a two-way operation since if you convert this instance into the raw VM, then you lose the transactor state.

source

pub const fn params(&self) -> &ConsensusParameters

Consensus parameters

source

pub fn gas_costs(&self) -> &GasCosts

Gas costs of opcodes

source

pub const fn tx_offset(&self) -> usize

Tx memory offset

source§

impl<S> Transactor<S, Script>

source

pub fn receipts(&self) -> Option<&[Receipt]>

Receipts after the execution of a transaction.

Follows the same criteria as Self::state_transition to return None.

source

pub fn backtrace(&self) -> Option<Backtrace>

Generate a backtrace when at least one receipt of ScriptResult was found.

source§

impl<S, Tx> Transactor<S, Tx>where S: InterpreterStorage,

source

pub fn deploy( &mut self, checked: Checked<Create> ) -> Result<Create, InterpreterError>

Deploys Create checked transactions.

source§

impl<S, Tx> Transactor<S, Tx>where S: InterpreterStorage, Tx: ExecutableTransaction, <Tx as IntoChecked>::Metadata: CheckedMetadata,

source

pub fn transact(&mut self, tx: Checked<Tx>) -> &mut Self

Execute a transaction, and return the new state of the transactor

Trait Implementations§

source§

impl<S, Tx> AsMut<S> for Transactor<S, Tx>where Tx: ExecutableTransaction,

source§

fn as_mut(&mut self) -> &mut S

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<S, Tx> AsRef<Interpreter<S, Tx>> for Transactor<S, Tx>where Tx: ExecutableTransaction,

source§

fn as_ref(&self) -> &Interpreter<S, Tx>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S, Tx> AsRef<S> for Transactor<S, Tx>where Tx: ExecutableTransaction,

source§

fn as_ref(&self) -> &S

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S: Debug, Tx: Debug> Debug for Transactor<S, Tx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S, Tx> Default for Transactor<S, Tx>where S: Default, Tx: ExecutableTransaction,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S, Tx> From<Interpreter<S, Tx>> for Transactor<S, Tx>where Tx: ExecutableTransaction,

source§

fn from(interpreter: Interpreter<S, Tx>) -> Self

Converts to this type from the input type.
source§

impl From<MemoryClient> for Transactor<MemoryStorage, Script>

source§

fn from(client: MemoryClient) -> Self

Converts to this type from the input type.
source§

impl<S, Tx> From<Transactor<S, Tx>> for Interpreter<S, Tx>where Tx: ExecutableTransaction,

source§

fn from(transactor: Transactor<S, Tx>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S, Tx> !RefUnwindSafe for Transactor<S, Tx>

§

impl<S, Tx> Send for Transactor<S, Tx>where S: Send, Tx: Send,

§

impl<S, Tx> Sync for Transactor<S, Tx>where S: Sync, Tx: Sync,

§

impl<S, Tx> Unpin for Transactor<S, Tx>where S: Unpin, Tx: Unpin,

§

impl<S, Tx> !UnwindSafe for Transactor<S, Tx>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyDebug for Twhere T: Any + Debug,

source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns a reference to the underlying type as Any.
§

impl<T> Base32Len for Twhere T: AsRef<[u8]>,

§

fn base32_len(&self) -> usize

Calculate the base32 serialized length
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<'f, T> CheckBase32<Vec<u5, Global>> for Twhere T: AsRef<[u8]>,

§

type Err = Error

Error type if conversion fails
§

fn check_base32( self ) -> Result<Vec<u5, Global>, <T as CheckBase32<Vec<u5, Global>>>::Err>

Check if all values are in range and return array-like struct of u5 values
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> StorageAsMut for T

source§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

source§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

source§

impl<T> StorageAsRef for T

source§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

source§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

§

impl<T> ToBase32 for Twhere T: AsRef<[u8]>,

§

fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where W: WriteBase32,

Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
§

fn to_base32(&self) -> Vec<u5, Global>

Convert Self to base32 vector
source§

impl<T> ToHex for Twhere T: AsRef<[u8]>,

source§

fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
source§

fn encode_hex_upper<U>(&self) -> Uwhere U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V