Nit: Update native loader to iterate accounts (#8640)

automerge
This commit is contained in:
Grimes 2020-03-04 17:10:22 -08:00 committed by GitHub
parent 1f2aaf3f98
commit 80aae18794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -7,8 +7,11 @@ use libloading::os::windows::*;
use log::*;
use num_derive::{FromPrimitive, ToPrimitive};
use solana_sdk::{
account::KeyedAccount, entrypoint_native, instruction::InstructionError,
program_utils::DecodeError, pubkey::Pubkey,
account::KeyedAccount,
entrypoint_native,
instruction::InstructionError,
program_utils::{next_keyed_account, DecodeError},
pubkey::Pubkey,
};
use std::{env, path::PathBuf, str};
use thiserror::Error;
@ -85,9 +88,10 @@ pub fn invoke_entrypoint(
instruction_data: &[u8],
symbol_cache: &SymbolCache,
) -> Result<(), InstructionError> {
// dispatch it
let (names, params) = keyed_accounts.split_at(1);
let name_vec = &names[0].try_account_ref()?.data;
let mut keyed_accounts_iter = keyed_accounts.iter();
let program = next_keyed_account(&mut keyed_accounts_iter)?;
let params = keyed_accounts_iter.as_slice();
let name_vec = &program.try_account_ref()?.data;
if let Some(entrypoint) = symbol_cache.read().unwrap().get(name_vec) {
unsafe {
return entrypoint(program_id, params, instruction_data);