Route program_id to program entrypoint

This commit is contained in:
Michael Vines
2018-11-17 17:02:14 -08:00
committed by Grimes
parent ff386d6585
commit 3822c29415
11 changed files with 77 additions and 35 deletions

View File

@ -1,12 +1,16 @@
use account::KeyedAccount;
use pubkey::Pubkey;
// All native programs export a symbol named process()
pub const ENTRYPOINT: &str = "process";
// Native program ENTRYPOINT prototype
pub type Entrypoint =
unsafe extern "C" fn(keyed_accounts: &mut [KeyedAccount], data: &[u8], tick_height: u64)
-> bool;
pub type Entrypoint = unsafe extern "C" fn(
program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],
data: &[u8],
tick_height: u64,
) -> bool;
// Convenience macro to define the native program entrypoint. Supply a fn to this macro that
// conforms to the `Entrypoint` type signature.
@ -14,8 +18,13 @@ pub type Entrypoint =
macro_rules! solana_entrypoint(
($entrypoint:ident) => (
#[no_mangle]
pub extern "C" fn process(keyed_accounts: &mut [KeyedAccount], data: &[u8], tick_height: u64) -> bool {
return $entrypoint(keyed_accounts, data, tick_height);
pub extern "C" fn process(
program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],
data: &[u8],
tick_height: u64
) -> bool {
return $entrypoint(program_id, keyed_accounts, data, tick_height);
}
)
);