Skip to main content

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<T>( transaction_accounts: Vec<(Pubkey, T)>, rent: Rent, instruction_stack_capacity: usize, instruction_trace_capacity: usize, ) -> TransactionContext
where T: Into<StoredAccount>,

Constructs a new TransactionContext

The transaction_accounts parameter accepts any type that can be converted into StoredAccount, including AccountSharedData for convenience.

Source

pub fn set_remove_accounts_executable_flag_checks(&mut self, enabled: bool)

Source

pub fn add_account(&mut self, account: (Pubkey, StoredAccount))

Source

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

Used in mock_process_instruction

Source

pub fn accounts(&self) -> &TransactionAccounts

Source

pub fn touch_fee_payer(&self)

Touch fee payer.

This is required for OCC executor as all transactions are executed in parallel and for sponsored transactions the fee payer may not get touched during execution since it was “touched” by the TransactionBatchProcessor when it deducted the fee.

The fee payer must be explicitly touched if the transaction is executed in the OCC batch so that the scheduler is able to validate and re-execute transactions that in the same batch use the fee payer.

Source

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

Source

pub fn account_keys(&self) -> impl Iterator<Item = &Pubkey>

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<&Pubkey, InstructionError>

Searches for an account by its key

Source

pub fn get_account_at_index( &self, index_in_transaction: u16, ) -> Result<&RefCell<StoredAccount>, InstructionError>

Searches for an account by its key

Source

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

Searches for an account by its key

Source

pub fn find_index_of_program_account(&self, pubkey: &Pubkey) -> Option<u16>

Searches for a program account by its key

Source

pub fn get_instruction_trace_capacity(&self) -> usize

Gets the max length of the InstructionContext trace

Source

pub fn get_instruction_trace_length(&self) -> usize

Returns the instruction trace length.

Not counting the last empty InstructionContext 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 an InstructionContext by its index in the trace

Source

pub fn get_instruction_context_at_index_in_trace_mut( &mut self, index_in_trace: usize, ) -> Result<&mut InstructionContext, InstructionError>

Source

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

Gets an InstructionContext by its nesting level in the stack

Source

pub fn get_instruction_context_at_nesting_level_mut( &mut self, nesting_level: usize, ) -> Result<&mut InstructionContext, InstructionError>

Source

pub fn get_instruction_stack_capacity(&self) -> usize

Gets the max height of the InstructionContext stack

Source

pub fn get_instruction_context_stack_height(&self) -> usize

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

Source

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

Returns the current InstructionContext

Source

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

Source

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

Returns the InstructionContext to configure for the next invocation.

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

Source

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

Pushes the next InstructionContext

Source

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

Pops the current InstructionContext

Source

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

Gets the return data of the current InstructionContext or any above

Source

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

Set the return data of the current InstructionContext

Source

pub fn accounts_resize_delta(&self) -> Result<i64, InstructionError>

Returns the accounts resize delta

Trait Implementations§

Source§

impl Clone for TransactionContext

Source§

fn clone(&self) -> TransactionContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransactionContext

Source§

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

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

impl PartialEq for TransactionContext

Source§

fn eq(&self, other: &TransactionContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TransactionContext

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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