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
pub fn new( transaction_accounts: Vec<TransactionAccount>, rent: Rent, instruction_stack_capacity: usize, instruction_trace_capacity: usize, ) -> Self
Constructs a new TransactionContext
sourcepub fn deconstruct_without_keys(
self,
) -> Result<Vec<AccountSharedData>, InstructionError>
pub fn deconstruct_without_keys( self, ) -> Result<Vec<AccountSharedData>, InstructionError>
Used in mock_process_instruction
pub fn accounts(&self) -> &Rc<TransactionAccounts>
sourcepub fn set_signature(&mut self, signature: &Signature)
pub fn set_signature(&mut self, signature: &Signature)
Stores the signature of the current transaction
sourcepub fn get_signature(&self) -> &Signature
pub fn get_signature(&self) -> &Signature
Returns the signature of the current transaction
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 get_account_at_index(
&self,
index_in_transaction: IndexOfAccount,
) -> Result<&RefCell<AccountSharedData>, InstructionError>
pub fn get_account_at_index( &self, index_in_transaction: IndexOfAccount, ) -> Result<&RefCell<AccountSharedData>, 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 find_index_of_program_account(
&self,
pubkey: &Pubkey,
) -> Option<IndexOfAccount>
pub fn find_index_of_program_account( &self, pubkey: &Pubkey, ) -> Option<IndexOfAccount>
Searches for a program 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 InstructionContext 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 InstructionContext 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 an InstructionContext 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 an InstructionContext 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 InstructionContext stack
sourcepub fn get_instruction_context_stack_height(&self) -> usize
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
sourcepub fn get_current_instruction_context(
&self,
) -> Result<&InstructionContext, InstructionError>
pub fn get_current_instruction_context( &self, ) -> Result<&InstructionContext, InstructionError>
Returns the current InstructionContext
sourcepub fn get_next_instruction_context(
&mut self,
) -> Result<&mut InstructionContext, InstructionError>
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.
sourcepub fn push(&mut self) -> Result<(), InstructionError>
pub fn push(&mut self) -> Result<(), InstructionError>
Pushes the next InstructionContext
sourcepub fn pop(&mut self) -> Result<(), InstructionError>
pub fn pop(&mut self) -> Result<(), InstructionError>
Pops the current InstructionContext
sourcepub fn get_return_data(&self) -> (&Pubkey, &[u8])
pub fn get_return_data(&self) -> (&Pubkey, &[u8])
Gets the return data of the current InstructionContext 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 InstructionContext
sourcepub fn accounts_resize_delta(&self) -> Result<i64, InstructionError>
pub fn accounts_resize_delta(&self) -> Result<i64, InstructionError>
Returns the accounts resize delta
Trait Implementations§
source§impl Clone for TransactionContext
impl Clone for TransactionContext
source§fn clone(&self) -> TransactionContext
fn clone(&self) -> TransactionContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransactionContext
impl Debug for TransactionContext
source§impl From<TransactionContext> for ExecutionRecord
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
fn from(context: TransactionContext) -> Self
source§impl PartialEq for TransactionContext
impl PartialEq for TransactionContext
impl StructuralPartialEq for TransactionContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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