Refactoring: Move KeyedAccounts to InvokeContext (#15410)
Collects all parametric occurrences and the construction of keyed_accounts and puts them into InvokeContext.
This commit is contained in:
committed by
GitHub
parent
015bc034a5
commit
9dfcb921cf
@ -25,7 +25,6 @@ use {
|
||||
hash::Hash,
|
||||
instruction::Instruction,
|
||||
instruction::InstructionError,
|
||||
keyed_account::KeyedAccount,
|
||||
message::Message,
|
||||
native_token::sol_to_lamports,
|
||||
process_instruction::{
|
||||
@ -99,12 +98,13 @@ fn get_invoke_context<'a>() -> &'a mut dyn InvokeContext {
|
||||
pub fn builtin_process_instruction(
|
||||
process_instruction: solana_sdk::entrypoint::ProcessInstruction,
|
||||
program_id: &Pubkey,
|
||||
keyed_accounts: &[KeyedAccount],
|
||||
input: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
set_invoke_context(invoke_context);
|
||||
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
|
||||
// Copy all the accounts into a HashMap to ensure there are no duplicates
|
||||
let mut accounts: HashMap<Pubkey, Account> = keyed_accounts
|
||||
.iter()
|
||||
@ -172,13 +172,11 @@ macro_rules! processor {
|
||||
($process_instruction:expr) => {
|
||||
Some(
|
||||
|program_id: &Pubkey,
|
||||
keyed_accounts: &[solana_sdk::keyed_account::KeyedAccount],
|
||||
input: &[u8],
|
||||
invoke_context: &mut dyn solana_sdk::process_instruction::InvokeContext| {
|
||||
$crate::builtin_process_instruction(
|
||||
$process_instruction,
|
||||
program_id,
|
||||
keyed_accounts,
|
||||
input,
|
||||
invoke_context,
|
||||
)
|
||||
|
Reference in New Issue
Block a user