Struct solana_sdk::transaction_context::InstructionContext
source · [−]pub struct InstructionContext { /* private fields */ }
Expand description
Loaded instruction shared between runtime and programs.
This context is valid for the entire duration of a (possibly cross program) instruction being processed.
Implementations
sourceimpl InstructionContext
impl InstructionContext
sourcepub fn new(
nesting_level: usize,
program_accounts: &[usize],
instruction_accounts: &[InstructionAccount],
instruction_data: &[u8]
) -> Self
pub fn new(
nesting_level: usize,
program_accounts: &[usize],
instruction_accounts: &[InstructionAccount],
instruction_data: &[u8]
) -> Self
New
sourcepub fn get_stack_height(&self) -> usize
pub fn get_stack_height(&self) -> usize
How many Instructions were on the stack after this one was pushed
That is the number of nested parent Instructions plus one (itself).
sourcepub fn get_number_of_program_accounts(&self) -> usize
pub fn get_number_of_program_accounts(&self) -> usize
Number of program accounts
sourcepub fn get_number_of_instruction_accounts(&self) -> usize
pub fn get_number_of_instruction_accounts(&self) -> usize
Number of accounts in this Instruction (without program accounts)
sourcepub fn check_number_of_instruction_accounts(
&self,
expected_at_least: usize
) -> Result<(), InstructionError>
pub fn check_number_of_instruction_accounts(
&self,
expected_at_least: usize
) -> Result<(), InstructionError>
Assert that enough account were supplied to this Instruction
sourcepub fn get_instruction_data(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn get_instruction_data(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Data parameter for the programs process_instruction
handler
sourcepub fn find_index_of_program_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
pub fn find_index_of_program_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
Searches for a program account by its key
sourcepub fn find_index_of_instruction_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
pub fn find_index_of_instruction_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
Searches for an instruction account by its key
sourcepub fn get_index_of_program_account_in_transaction(
&self,
program_account_index: usize
) -> Result<usize, InstructionError>
pub fn get_index_of_program_account_in_transaction(
&self,
program_account_index: usize
) -> Result<usize, InstructionError>
Translates the given instruction wide program_account_index into a transaction wide index
sourcepub fn get_index_of_instruction_account_in_transaction(
&self,
instruction_account_index: usize
) -> Result<usize, InstructionError>
pub fn get_index_of_instruction_account_in_transaction(
&self,
instruction_account_index: usize
) -> Result<usize, InstructionError>
Translates the given instruction wide instruction_account_index into a transaction wide index
sourcepub fn is_instruction_account_duplicate(
&self,
instruction_account_index: usize
) -> Result<Option<usize>, InstructionError>
pub fn is_instruction_account_duplicate(
&self,
instruction_account_index: usize
) -> Result<Option<usize>, InstructionError>
Returns Some(instruction_account_index)
if this is a duplicate
and None
if it is the first account with this key
sourcepub fn get_last_program_key<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<&'b Pubkey, InstructionError>
pub fn get_last_program_key<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<&'b Pubkey, InstructionError>
Gets the key of the last program account of this Instruction
sourcepub fn try_borrow_last_program_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<BorrowedAccount<'a>, InstructionError>
pub fn try_borrow_last_program_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<BorrowedAccount<'a>, InstructionError>
Gets the last program account of this Instruction
sourcepub fn try_borrow_program_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
program_account_index: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
pub fn try_borrow_program_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
program_account_index: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
Tries to borrow a program account from this Instruction
sourcepub fn try_borrow_instruction_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
instruction_account_index: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
pub fn try_borrow_instruction_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
instruction_account_index: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
Gets an instruction account of this Instruction
sourcepub fn is_instruction_account_signer(
&self,
instruction_account_index: usize
) -> Result<bool, InstructionError>
pub fn is_instruction_account_signer(
&self,
instruction_account_index: usize
) -> Result<bool, InstructionError>
Returns whether an instruction account is a signer
sourcepub fn is_instruction_account_writable(
&self,
instruction_account_index: usize
) -> Result<bool, InstructionError>
pub fn is_instruction_account_writable(
&self,
instruction_account_index: usize
) -> Result<bool, InstructionError>
Returns whether an instruction account is writable
sourcepub fn get_signers(
&self,
transaction_context: &TransactionContext
) -> HashSet<Pubkey>
pub fn get_signers(
&self,
transaction_context: &TransactionContext
) -> HashSet<Pubkey>
Calculates the set of all keys of signer instruction accounts in this Instruction
Trait Implementations
sourceimpl Clone for InstructionContext
impl Clone for InstructionContext
sourcefn clone(&self) -> InstructionContext
fn clone(&self) -> InstructionContext
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for InstructionContext
impl Send for InstructionContext
impl Sync for InstructionContext
impl Unpin for InstructionContext
impl UnwindSafe for InstructionContext
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