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<TransactionAccount>, rent: Rent, instruction_stack_capacity: usize, instruction_trace_capacity: usize ) -> Self

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 set_signature(&mut self, signature: &Signature)

Stores the signature of the current transaction

source

pub fn get_signature(&self) -> &Signature

Returns the signature of the current transaction

source

pub fn get_number_of_accounts(&self) -> IndexOfAccount

Returns the total number of accounts loaded in this Transaction

source

pub fn get_key_of_account_at_index( &self, index_in_transaction: IndexOfAccount ) -> Result<&Pubkey, InstructionError>

Searches for an account by its key

source

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

Searches for an account by its key

source

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

Searches for an account by its key

source

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

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_nesting_level( &self, nesting_level: usize ) -> Result<&InstructionContext, InstructionError>

Gets an InstructionContext by its nesting level in the stack

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 solana_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_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 copy 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

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

impl From<TransactionContext> for ExecutionRecord

Used by the bank in the runtime to write back the processed accounts and recorded instructions

source§

fn from(context: TransactionContext) -> Self

Converts to this type from the input type.
source§

impl PartialEq for TransactionContext

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> AbiExample for T

source§

default fn example() -> T

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

source§

const ALIGN: usize = _

The alignment of pointer.
§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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