macro_rules! program_entrypoint {
( $process_instruction:expr ) => { ... };
( $process_instruction:expr, $maximum:expr ) => { ... };
}Expand description
Declare the program entrypoint.
This macro is similar to the crate::entrypoint! macro, but it does not
set up a global allocator nor a panic handler. This is useful when the
program will set up its own allocator and panic handler.
The first argument is the name of a function with this type signature:
fn process_instruction(
program_id: &Address, // Address of the account the program was loaded into
accounts: &[AccountView], // All accounts required to process the instruction
instruction_data: &[u8], // Serialized instruction-specific data
) -> ProgramResult;The argument is defined as an expr, which allows the use of any function
pointer not just identifiers in the current scope.
There is a second optional argument that allows to specify the maximum
number of accounts expected by instructions of the program. This is useful
to reduce the stack size requirement for the entrypoint, as the default is
set to MAX_TX_ACCOUNTS. If the program receives more accounts than the
specified maximum, these accounts will be ignored.