Struct solana_sdk::transaction_context::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
sourceimpl TransactionContext
impl TransactionContext
sourcepub fn new(
transaction_accounts: Vec<TransactionAccount>,
instruction_context_capacity: usize,
number_of_instructions_at_transaction_level: usize
) -> Self
pub fn new(
transaction_accounts: Vec<TransactionAccount>,
instruction_context_capacity: usize,
number_of_instructions_at_transaction_level: usize
) -> Self
Constructs a new TransactionContext
sourcepub fn deconstruct(
self
) -> (Vec<TransactionAccount>, Vec<Vec<InstructionContext>>)
pub fn deconstruct(
self
) -> (Vec<TransactionAccount>, Vec<Vec<InstructionContext>>)
Used by the bank in the runtime to write back the processed accounts and recorded instructions
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
sourcepub fn get_number_of_accounts(&self) -> usize
pub fn get_number_of_accounts(&self) -> usize
Returns the total number of accounts loaded in this Transaction
sourcepub fn get_key_of_account_at_index(
&self,
index_in_transaction: usize
) -> Result<&Pubkey, InstructionError>
pub fn get_key_of_account_at_index(
&self,
index_in_transaction: usize
) -> Result<&Pubkey, InstructionError>
Searches for an account by its key
sourcepub fn get_keys_of_accounts(&self) -> &[Pubkey]
pub fn get_keys_of_accounts(&self) -> &[Pubkey]
Returns the keys for the accounts loaded in this Transaction
sourcepub fn get_account_at_index(
&self,
index_in_transaction: usize
) -> Result<&RefCell<AccountSharedData>, InstructionError>
pub fn get_account_at_index(
&self,
index_in_transaction: usize
) -> Result<&RefCell<AccountSharedData>, InstructionError>
Searches for an account by its key
sourcepub fn find_index_of_account(&self, pubkey: &Pubkey) -> Option<usize>
pub fn find_index_of_account(&self, pubkey: &Pubkey) -> Option<usize>
Searches for an account by its key
sourcepub fn find_index_of_program_account(&self, pubkey: &Pubkey) -> Option<usize>
pub fn find_index_of_program_account(&self, pubkey: &Pubkey) -> Option<usize>
Searches for a program account by its key
sourcepub fn get_instruction_context_at(
&self,
level: usize
) -> Result<&InstructionContext, InstructionError>
pub fn get_instruction_context_at(
&self,
level: usize
) -> Result<&InstructionContext, InstructionError>
Gets an InstructionContext by its nesting level in the stack
sourcepub fn get_instruction_context_capacity(&self) -> usize
pub fn get_instruction_context_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 push(
&mut self,
program_accounts: &[usize],
instruction_accounts: &[InstructionAccount],
instruction_data: &[u8],
record_instruction_in_transaction_context_push: bool
) -> Result<(), InstructionError>
pub fn push(
&mut self,
program_accounts: &[usize],
instruction_accounts: &[InstructionAccount],
instruction_data: &[u8],
record_instruction_in_transaction_context_push: bool
) -> Result<(), InstructionError>
Pushes a new 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 record_instruction(&mut self, instruction: InstructionContext)
pub fn record_instruction(&mut self, instruction: InstructionContext)
Used by the runtime when a new CPI instruction begins
Deprecated, automatically done in push() once record_instruction_in_transaction_context_push is activated.
sourcepub fn get_instruction_trace(&self) -> &InstructionTrace
pub fn get_instruction_trace(&self) -> &InstructionTrace
Returns instruction trace
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for TransactionContext
impl Send for TransactionContext
impl !Sync for TransactionContext
impl Unpin for TransactionContext
impl UnwindSafe for TransactionContext
Blanket Implementations
sourceimpl<T> AbiExample for T
impl<T> AbiExample for T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more