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
impl TransactionContext
Sourcepub fn new(
transaction_accounts: Vec<TransactionAccount>,
rent: Rent,
instruction_stack_capacity: usize,
instruction_trace_capacity: usize,
) -> Self
Available on non-target_os=solana
only.
pub fn new( transaction_accounts: Vec<TransactionAccount>, rent: Rent, instruction_stack_capacity: usize, instruction_trace_capacity: usize, ) -> Self
target_os=solana
only.Constructs a new TransactionContext
Sourcepub fn deconstruct_without_keys(
self,
) -> Result<Vec<AccountSharedData>, InstructionError>
Available on non-target_os=solana
only.
pub fn deconstruct_without_keys( self, ) -> Result<Vec<AccountSharedData>, InstructionError>
target_os=solana
only.Used in mock_process_instruction
pub fn accounts(&self) -> &Rc<TransactionAccounts>
target_os=solana
only.Sourcepub fn get_number_of_accounts(&self) -> IndexOfAccount
pub fn get_number_of_accounts(&self) -> IndexOfAccount
Returns the total number of accounts loaded in this Transaction
Sourcepub fn get_key_of_account_at_index(
&self,
index_in_transaction: IndexOfAccount,
) -> Result<&Pubkey, InstructionError>
pub fn get_key_of_account_at_index( &self, index_in_transaction: IndexOfAccount, ) -> Result<&Pubkey, InstructionError>
Searches for an account by its key
Sourcepub fn find_index_of_account(&self, pubkey: &Pubkey) -> Option<IndexOfAccount>
pub fn find_index_of_account(&self, pubkey: &Pubkey) -> Option<IndexOfAccount>
Searches for an account by its key
Sourcepub fn get_instruction_trace_capacity(&self) -> usize
pub fn get_instruction_trace_capacity(&self) -> usize
Gets the max length of the instruction trace
Sourcepub fn get_instruction_trace_length(&self) -> usize
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()
.
Sourcepub fn get_instruction_context_at_index_in_trace(
&self,
index_in_trace: usize,
) -> Result<InstructionContext<'_>, InstructionError>
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
Sourcepub fn get_instruction_context_at_nesting_level(
&self,
nesting_level: usize,
) -> Result<InstructionContext<'_>, InstructionError>
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
Sourcepub fn get_instruction_stack_capacity(&self) -> usize
pub fn get_instruction_stack_capacity(&self) -> usize
Gets the max height of the instruction stack
Sourcepub fn get_instruction_stack_height(&self) -> usize
pub fn get_instruction_stack_height(&self) -> usize
Gets instruction stack height, top-level instructions are height
solana_instruction::TRANSACTION_LEVEL_STACK_HEIGHT
Sourcepub fn get_current_instruction_context(
&self,
) -> Result<InstructionContext<'_>, InstructionError>
pub fn get_current_instruction_context( &self, ) -> Result<InstructionContext<'_>, InstructionError>
Returns a view on the current instruction
Sourcepub fn get_next_instruction_context(
&self,
) -> Result<InstructionContext<'_>, InstructionError>
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
Sourcepub fn configure_next_instruction(
&mut self,
program_index: IndexOfAccount,
instruction_accounts: Vec<InstructionAccount>,
deduplication_map: Vec<u8>,
instruction_data: &[u8],
) -> Result<(), InstructionError>
pub fn configure_next_instruction( &mut self, program_index: IndexOfAccount, 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.
Sourcepub fn configure_next_instruction_for_tests(
&mut self,
program_index: IndexOfAccount,
instruction_accounts: Vec<InstructionAccount>,
instruction_data: &[u8],
) -> Result<(), InstructionError>
pub fn configure_next_instruction_for_tests( &mut self, program_index: IndexOfAccount, instruction_accounts: Vec<InstructionAccount>, instruction_data: &[u8], ) -> Result<(), InstructionError>
A version of configure_next_instruction
to help creating the deduplication map in tests
Sourcepub fn push(&mut self) -> Result<(), InstructionError>
Available on non-target_os=solana
only.
pub fn push(&mut self) -> Result<(), InstructionError>
target_os=solana
only.Pushes the next instruction
Sourcepub fn pop(&mut self) -> Result<(), InstructionError>
Available on non-target_os=solana
only.
pub fn pop(&mut self) -> Result<(), InstructionError>
target_os=solana
only.Pops the current instruction
Sourcepub fn get_return_data(&self) -> (&Pubkey, &[u8])
pub fn get_return_data(&self) -> (&Pubkey, &[u8])
Gets the return data of the current instruction or any above
Sourcepub fn set_return_data(
&mut self,
program_id: Pubkey,
data: Vec<u8>,
) -> Result<(), InstructionError>
pub fn set_return_data( &mut self, program_id: Pubkey, data: Vec<u8>, ) -> Result<(), InstructionError>
Set the return data of the current instruction
Sourcepub fn accounts_resize_delta(&self) -> i64
pub fn accounts_resize_delta(&self) -> i64
Returns the accounts resize delta
Sourcepub fn access_violation_handler(
&self,
stricter_abi_and_runtime_constraints: bool,
account_data_direct_mapping: bool,
) -> AccessViolationHandler
pub fn access_violation_handler( &self, stricter_abi_and_runtime_constraints: bool, account_data_direct_mapping: bool, ) -> AccessViolationHandler
Returns a new account data write access handler
Trait Implementations§
Source§impl Debug for TransactionContext
impl Debug for TransactionContext
Source§impl From<TransactionContext> for ExecutionRecord
Available on non-target_os=solana
only.Used by the bank in the runtime to write back the processed accounts and recorded instructions
impl From<TransactionContext> for ExecutionRecord
target_os=solana
only.Used by the bank in the runtime to write back the processed accounts and recorded instructions
Source§fn from(context: TransactionContext) -> Self
fn from(context: TransactionContext) -> Self
Auto Trait Implementations§
impl Freeze for TransactionContext
impl !RefUnwindSafe for TransactionContext
impl !Send for TransactionContext
impl !Sync for TransactionContext
impl Unpin for TransactionContext
impl !UnwindSafe for TransactionContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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