Struct InvokeContext

Source
pub struct InvokeContext<'a> {
    pub transaction_context: &'a mut TransactionContext,
    pub sysvar_cache: Cow<'a, SysvarCache>,
    pub trace_log: Vec<[u64; 12]>,
    pub tx_executor_cache: Rc<RefCell<TransactionExecutorCache>>,
    pub feature_set: Arc<FeatureSet>,
    pub timings: ExecuteDetailsTimings,
    pub blockhash: Hash,
    pub scoobies_per_signature: u64,
    /* private fields */
}

Fields§

§transaction_context: &'a mut TransactionContext§sysvar_cache: Cow<'a, SysvarCache>§trace_log: Vec<[u64; 12]>§tx_executor_cache: Rc<RefCell<TransactionExecutorCache>>§feature_set: Arc<FeatureSet>§timings: ExecuteDetailsTimings§blockhash: Hash§scoobies_per_signature: u64

Implementations§

Source§

impl<'a> InvokeContext<'a>

Source

pub fn new( transaction_context: &'a mut TransactionContext, rent: Rent, builtin_programs: &'a [BuiltinProgram], sysvar_cache: Cow<'a, SysvarCache>, log_collector: Option<Rc<RefCell<LogCollector>>>, compute_budget: ComputeBudget, tx_executor_cache: Rc<RefCell<TransactionExecutorCache>>, feature_set: Arc<FeatureSet>, blockhash: Hash, scoobies_per_signature: u64, prev_accounts_data_len: u64, ) -> Self

Source

pub fn new_mock( transaction_context: &'a mut TransactionContext, builtin_programs: &'a [BuiltinProgram], ) -> Self

Source

pub fn push(&mut self) -> Result<(), InstructionError>

Push a stack frame onto the invocation stack

Source

pub fn pop(&mut self) -> Result<(), InstructionError>

Pop a stack frame from the invocation stack

Source

pub fn get_stack_height(&self) -> usize

Current height of the invocation stack, top level instructions are height cbe_sdk::instruction::TRANSACTION_LEVEL_STACK_HEIGHT

Source

pub fn native_invoke( &mut self, instruction: Instruction, signers: &[Pubkey], ) -> Result<(), InstructionError>

Entrypoint for a cross-program invocation from a builtin program

Source

pub fn prepare_instruction( &mut self, instruction: &Instruction, signers: &[Pubkey], ) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>

Helper to prepare for process_instruction()

Source

pub fn process_instruction( &mut self, instruction_data: &[u8], instruction_accounts: &[InstructionAccount], program_indices: &[IndexOfAccount], compute_units_consumed: &mut u64, timings: &mut ExecuteTimings, ) -> Result<(), InstructionError>

Processes an instruction and returns how many compute units were used

Source

pub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>

Get this invocation’s LogCollector

Source

pub fn consume_checked(&self, amount: u64) -> Result<(), InstructionError>

Consume compute units

Source

pub fn mock_set_remaining(&self, remaining: u64)

Set compute units

Only use for tests and benchmarks

Source

pub fn get_accounts_data_meter(&self) -> &AccountsDataMeter

Get this invocation’s AccountsDataMeter

Source

pub fn get_compute_budget(&self) -> &ComputeBudget

Get this invocation’s compute budget

Source

pub fn get_sysvar_cache(&self) -> &SysvarCache

Get cached sysvars

Source

pub fn set_syscall_context( &mut self, check_aligned: bool, check_size: bool, orig_account_lengths: Vec<usize>, allocator: Rc<RefCell<dyn Alloc>>, ) -> Result<(), InstructionError>

Source

pub fn get_check_aligned(&self) -> bool

Source

pub fn get_check_size(&self) -> bool

Source

pub fn get_orig_account_lengths(&self) -> Result<&[usize], InstructionError>

Get the original account lengths

Source

pub fn get_allocator(&self) -> Result<Rc<RefCell<dyn Alloc>>, InstructionError>

Trait Implementations§

Source§

impl<'a> ContextObject for InvokeContext<'a>

Source§

fn trace(&mut self, state: [u64; 12])

Called for every instruction executed when tracing is enabled
Source§

fn consume(&mut self, amount: u64)

Consume instructions from meter
Source§

fn get_remaining(&self) -> u64

Get the number of remaining instructions allowed

Auto Trait Implementations§

§

impl<'a> !Freeze for InvokeContext<'a>

§

impl<'a> !RefUnwindSafe for InvokeContext<'a>

§

impl<'a> !Send for InvokeContext<'a>

§

impl<'a> !Sync for InvokeContext<'a>

§

impl<'a> Unpin for InvokeContext<'a>

§

impl<'a> !UnwindSafe for InvokeContext<'a>

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,