Document InvokeContext trait (#10514)
This commit is contained in:
@ -148,18 +148,25 @@ macro_rules! declare_loader(
|
|||||||
|
|
||||||
pub type ProcessInstruction = fn(&Pubkey, &[KeyedAccount], &[u8]) -> Result<(), InstructionError>;
|
pub type ProcessInstruction = fn(&Pubkey, &[KeyedAccount], &[u8]) -> Result<(), InstructionError>;
|
||||||
|
|
||||||
/// Cross-program invocation context passed to loaders
|
/// Invocation context passed to loaders
|
||||||
pub trait InvokeContext {
|
pub trait InvokeContext {
|
||||||
|
/// Push a program ID on to the invocation stack
|
||||||
fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError>;
|
fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError>;
|
||||||
|
/// Pop a program ID off of the invocation stack
|
||||||
fn pop(&mut self);
|
fn pop(&mut self);
|
||||||
|
/// Verify and update PreAccount state based on program execution
|
||||||
fn verify_and_update(
|
fn verify_and_update(
|
||||||
&mut self,
|
&mut self,
|
||||||
message: &Message,
|
message: &Message,
|
||||||
instruction: &CompiledInstruction,
|
instruction: &CompiledInstruction,
|
||||||
accounts: &[Rc<RefCell<Account>>],
|
accounts: &[Rc<RefCell<Account>>],
|
||||||
) -> Result<(), InstructionError>;
|
) -> Result<(), InstructionError>;
|
||||||
|
/// Get the program ID of the currently executing program
|
||||||
fn get_caller(&self) -> Result<&Pubkey, InstructionError>;
|
fn get_caller(&self) -> Result<&Pubkey, InstructionError>;
|
||||||
|
/// Get a list of built-in programs
|
||||||
fn get_programs(&self) -> &[(Pubkey, ProcessInstruction)];
|
fn get_programs(&self) -> &[(Pubkey, ProcessInstruction)];
|
||||||
|
/// Check if logging is enabled
|
||||||
fn log_enabled(&self) -> bool;
|
fn log_enabled(&self) -> bool;
|
||||||
|
/// Log a message
|
||||||
fn log(&mut self, message: &str);
|
fn log(&mut self, message: &str);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user