Document InvokeContext trait (#10514)

This commit is contained in:
Jack May 2020-06-11 15:31:13 -07:00 committed by GitHub
parent 526eefac97
commit b03a347803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

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