Move entrypoint boilerplate into a macro
This commit is contained in:
parent
412ebfcaf2
commit
4bb88619fd
|
@ -1,22 +1,5 @@
|
|||
mod budget_processor;
|
||||
|
||||
use crate::budget_processor::process_instruction;
|
||||
use log::*;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::solana_entrypoint;
|
||||
use solana_sdk::transaction::InstructionError;
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(
|
||||
program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
data: &[u8],
|
||||
tick_height: u64,
|
||||
) -> Result<(), InstructionError> {
|
||||
solana_logger::setup();
|
||||
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
process_instruction(program_id, keyed_accounts, data, tick_height)
|
||||
}
|
||||
solana_sdk::process_instruction_entrypoint!(process_instruction);
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
use log::*;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::solana_entrypoint;
|
||||
use solana_sdk::transaction::InstructionError;
|
||||
|
||||
solana_sdk::process_instruction_entrypoint!(process_instruction);
|
||||
fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
|
@ -26,20 +26,6 @@ fn process_instruction(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(
|
||||
program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
data: &[u8],
|
||||
tick_height: u64,
|
||||
) -> Result<(), InstructionError> {
|
||||
solana_logger::setup();
|
||||
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
process_instruction(program_id, keyed_accounts, data, tick_height)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -20,12 +20,32 @@ macro_rules! solana_entrypoint(
|
|||
($entrypoint:ident) => (
|
||||
#[no_mangle]
|
||||
pub extern "C" fn process(
|
||||
program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
program_id: &solana_sdk::pubkey::Pubkey,
|
||||
keyed_accounts: &mut [solana_sdk::account::KeyedAccount],
|
||||
data: &[u8],
|
||||
tick_height: u64
|
||||
) -> Result<(), InstructionError> {
|
||||
) -> Result<(), solana_sdk::transaction::InstructionError> {
|
||||
$entrypoint(program_id, keyed_accounts, data, tick_height)
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Macro to define an entrypoint from a native `process_instruction` function.
|
||||
#[macro_export]
|
||||
macro_rules! process_instruction_entrypoint(
|
||||
($process_instruction:ident) => (
|
||||
solana_sdk::solana_entrypoint!(process_instruction_entrypoint);
|
||||
fn process_instruction_entrypoint(
|
||||
program_id: &solana_sdk::pubkey::Pubkey,
|
||||
keyed_accounts: &mut [solana_sdk::account::KeyedAccount],
|
||||
data: &[u8],
|
||||
tick_height: u64,
|
||||
) -> Result<(), solana_sdk::transaction::InstructionError> {
|
||||
solana_logger::setup();
|
||||
|
||||
log::trace!("process_instruction: {:?}", data);
|
||||
log::trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
$process_instruction(program_id, keyed_accounts, data, tick_height)
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue