Refactor: Use InstructionContext::get_instruction_data()
(#24014)
* Adds transaction_context and instruction_context where invoke_context.get_keyed_accounts() is used. * Use instruction_context.get_instruction_data() instead of an explicit parameter. * Removes instruction_data parameter from Executor::execute(). * Removes instruction_data parameter from ProcessInstructionWithContext.
This commit is contained in:
committed by
GitHub
parent
cf59c000d9
commit
1b45c509c3
@@ -111,12 +111,10 @@ fn bench_process_vote_instruction(
|
||||
invoke_context
|
||||
.push(&instruction_accounts, &[0], &instruction_data)
|
||||
.unwrap();
|
||||
assert!(solana_vote_program::vote_processor::process_instruction(
|
||||
1,
|
||||
&instruction_data,
|
||||
&mut invoke_context
|
||||
)
|
||||
.is_ok());
|
||||
assert!(
|
||||
solana_vote_program::vote_processor::process_instruction(1, &mut invoke_context)
|
||||
.is_ok()
|
||||
);
|
||||
invoke_context.pop().unwrap();
|
||||
});
|
||||
}
|
||||
|
@@ -18,11 +18,11 @@ use {
|
||||
|
||||
pub fn process_instruction(
|
||||
first_instruction_account: usize,
|
||||
data: &[u8],
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let transaction_context = &invoke_context.transaction_context;
|
||||
let instruction_context = transaction_context.get_current_instruction_context()?;
|
||||
let data = instruction_context.get_instruction_data();
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
|
||||
trace!("process_instruction: {:?}", data);
|
||||
@@ -236,15 +236,9 @@ mod tests {
|
||||
instruction_accounts,
|
||||
None,
|
||||
expected_result,
|
||||
|first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut InvokeContext| {
|
||||
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
|
||||
invoke_context.feature_set = std::sync::Arc::new(FeatureSet::default());
|
||||
super::process_instruction(
|
||||
first_instruction_account,
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
)
|
||||
super::process_instruction(first_instruction_account, invoke_context)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user