TransactionContext

Struct TransactionContext 

Source
pub struct TransactionContext { /* private fields */ }
Expand description

Loaded transaction shared between runtime and programs.

This context is valid for the entire duration of a transaction being processed.

Implementations§

Source§

impl TransactionContext

Source

pub fn new( transaction_accounts: Vec<(Address, AccountSharedData)>, rent: Rent, instruction_stack_capacity: usize, instruction_trace_capacity: usize, ) -> TransactionContext

Constructs a new TransactionContext

Source

pub fn deconstruct_without_keys( self, ) -> Result<Vec<AccountSharedData>, InstructionError>

Used in mock_process_instruction

Source

pub fn accounts(&self) -> &Rc<TransactionAccounts>

Source

pub fn get_number_of_accounts(&self) -> u16

Returns the total number of accounts loaded in this Transaction

Source

pub fn get_key_of_account_at_index( &self, index_in_transaction: u16, ) -> Result<&Address, InstructionError>

Searches for an account by its key

Source

pub fn find_index_of_account(&self, pubkey: &Address) -> Option<u16>

Searches for an account by its key

Source

pub fn get_instruction_trace_capacity(&self) -> usize

Gets the max length of the instruction trace

Source

pub fn get_instruction_trace_length(&self) -> usize

Returns the instruction trace length.

Not counting the last empty instruction which is always pre-reserved for the next instruction. See also get_next_instruction_context().

Source

pub fn get_instruction_context_at_index_in_trace( &self, index_in_trace: usize, ) -> Result<InstructionContext<'_>, InstructionError>

Gets a view on an instruction by its index in the trace

Source

pub fn get_instruction_context_at_nesting_level( &self, nesting_level: usize, ) -> Result<InstructionContext<'_>, InstructionError>

Gets a view on the instruction by its nesting level in the stack

Source

pub fn get_instruction_stack_capacity(&self) -> usize

Gets the max height of the instruction stack

Source

pub fn get_instruction_stack_height(&self) -> usize

Gets instruction stack height, top-level instructions are height solana_instruction::TRANSACTION_LEVEL_STACK_HEIGHT

Source

pub fn get_current_instruction_context( &self, ) -> Result<InstructionContext<'_>, InstructionError>

Returns a view on the current instruction

Source

pub fn get_next_instruction_context( &self, ) -> Result<InstructionContext<'_>, InstructionError>

Returns a view on the next instruction. This function assumes it has already been configured with the correct values in prepare_next_instruction or prepare_next_top_level_instruction

Source

pub fn configure_next_instruction( &mut self, program_index: u16, instruction_accounts: Vec<InstructionAccount>, deduplication_map: Vec<u8>, instruction_data: &[u8], ) -> Result<(), InstructionError>

Configures the next instruction.

The last InstructionContext is always empty and pre-reserved for the next instruction.

Source

pub fn configure_next_instruction_for_tests( &mut self, program_index: u16, instruction_accounts: Vec<InstructionAccount>, instruction_data: &[u8], ) -> Result<(), InstructionError>

A version of configure_next_instruction to help creating the deduplication map in tests

Source

pub fn push(&mut self) -> Result<(), InstructionError>

Pushes the next instruction

Source

pub fn pop(&mut self) -> Result<(), InstructionError>

Pops the current instruction

Source

pub fn get_return_data(&self) -> (&Address, &[u8])

Gets the return data of the current instruction or any above

Source

pub fn set_return_data( &mut self, program_id: Address, data: Vec<u8>, ) -> Result<(), InstructionError>

Set the return data of the current instruction

Source

pub fn accounts_resize_delta(&self) -> i64

Returns the accounts resize delta

Source

pub fn access_violation_handler( &self, stricter_abi_and_runtime_constraints: bool, account_data_direct_mapping: bool, ) -> Box<dyn Fn(&mut MemoryRegion, u64, AccessType, u64, u64)>

Returns a new account data write access handler

Trait Implementations§

Source§

impl Debug for TransactionContext

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

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

Source§

fn vzip(self) -> V