/// Process a cross-program instruction
/// This method calls the instruction's program entrypoint function
Process a cross-program instruction
This method calls the instruction's program entrypoint function
Process a cross - program instruction This method calls the instruction ' s program entrypoint function
pub fn process_cross_program_instruction(
        &self,
        message: &Message,
        executable_accounts: &[(Pubkey, RefCell<Account>)],
        accounts: &[Rc<RefCell<Account>>],
        invoke_context: &mut dyn InvokeContext,
    ) -> Result<(), InstructionError> {
        if let Some(instruction) = message.instructions.get(0) {
            // Verify the calling program hasn't misbehaved
            invoke_context.verify_and_update(message, instruction, accounts)?;
            // Construct keyed accounts
            let keyed_accounts =
                Self::create_keyed_accounts(message, instruction, executable_accounts, accounts)?;
            // Invoke callee
            invoke_context.push(instruction.program_id(&message.account_keys))?;
            let mut result =
                self.process_instruction(&keyed_accounts, &instruction.data, invoke_context);
            if result.is_ok() {
                // Verify the called program has not misbehaved
                result = invoke_context.verify_and_update(message, instruction, accounts);
            }
            invoke_context.pop();
            result
        } else {
            // This function is always called with a valid instruction, if that changes return an error
            Err(InstructionError::GenericError)
        }
    }
pub fn process_cross_program_instruction ( & self , message : & Message , executable_accounts : & [ ( Pubkey , RefCell < Account > ) ] , accounts : & [ Rc < RefCell < Account > > ] , invoke_context : & mut dyn InvokeContext , ) -> Result < ( ) , InstructionError > { if let Some ( instruction ) = message . instructions . get ( 0 ) { // Verify the calling program hasn't misbehaved invoke_context . verify_and_update ( message , instruction , accounts ) ? ; // Construct keyed accounts let keyed_accounts = Self :: create_keyed_accounts ( message , instruction , executable_accounts , accounts ) ? ; // Invoke callee invoke_context . push ( instruction . program_id ( & message . account_keys ) ) ? ; let mut result = self . process_instruction ( & keyed_accounts , & instruction . data , invoke_context ) ; if result . is_ok ( ) { // Verify the called program has not misbehaved result = invoke_context . verify_and_update ( message , instruction , accounts ) ; } invoke_context . pop ( ) ; result } else { // This function is always called with a valid instruction, if that changes return an error Err ( InstructionError :: GenericError ) } }
Process a cross-program instruction
This method calls the instruction's program entrypoint function
Process a cross - program instruction This method calls the instruction ' s program entrypoint function
&self
message
&Message
executable_accounts
&[(Pubkey, RefCell<Account>)]
accounts
&[Rc<RefCell<Account>>]
invoke_context
&mut dyn InvokeContext