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_program_id_index(&self) -> usize
pub fn get_program_id_index(&self) -> usize
Get the index of the instruction’s program id
sourcepub fn get_program_id(&self, transaction_context: &TransactionContext) -> Pubkey
pub fn get_program_id(&self, transaction_context: &TransactionContext) -> Pubkey
Get the instruction’s program id
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_number_of_accounts(&self) -> usize
pub fn get_number_of_accounts(&self) -> usize
Number of accounts in 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_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
pub fn find_index_of_account(
&self,
transaction_context: &TransactionContext,
pubkey: &Pubkey
) -> Option<usize>
Searches for an account by its key
sourcepub fn get_index_in_transaction(
&self,
index_in_instruction: usize
) -> Result<usize, InstructionError>
pub fn get_index_in_transaction(
&self,
index_in_instruction: usize
) -> Result<usize, InstructionError>
Translates the given instruction wide index into a transaction wide index
sourcepub fn get_program_key<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<&'b Pubkey, InstructionError>
pub fn get_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 get_instruction_account_key<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
instruction_account_index: usize
) -> Result<&'b Pubkey, InstructionError>
pub fn get_instruction_account_key<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
instruction_account_index: usize
) -> Result<&'b Pubkey, InstructionError>
Gets the key of an instruction account (skipping program accounts)
sourcepub fn try_borrow_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
index_in_instruction: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
pub fn try_borrow_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext,
index_in_instruction: usize
) -> Result<BorrowedAccount<'a>, InstructionError>
Tries to borrow an account from this Instruction
sourcepub fn try_borrow_program_account<'a, 'b: 'a>(
&'a self,
transaction_context: &'b TransactionContext
) -> Result<BorrowedAccount<'a>, InstructionError>
pub fn try_borrow_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_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_signer(
&self,
index_in_instruction: usize
) -> Result<bool, InstructionError>
pub fn is_signer(
&self,
index_in_instruction: usize
) -> Result<bool, InstructionError>
Returns whether an account is a signer
sourcepub fn is_writable(
&self,
index_in_instruction: usize
) -> Result<bool, InstructionError>
pub fn is_writable(
&self,
index_in_instruction: usize
) -> Result<bool, InstructionError>
Returns whether an 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 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
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more