Rename process_transaction to process_instruction

This commit is contained in:
Greg Fitzgerald
2018-11-23 15:14:13 -07:00
parent cd488b7d07
commit b3af930153
5 changed files with 13 additions and 13 deletions

View File

@ -819,7 +819,7 @@ impl Bank {
// It's up to the contract to implement its own rules on moving funds // It's up to the contract to implement its own rules on moving funds
if system_program::check_id(&program_id) { if system_program::check_id(&program_id) {
if let Err(err) = if let Err(err) =
system_program::process_transaction(&tx, instruction_index, program_accounts) system_program::process_instruction(&tx, instruction_index, program_accounts)
{ {
let err = match err { let err = match err {
system_program::Error::ResultWithNegativeTokens(i) => { system_program::Error::ResultWithNegativeTokens(i) => {
@ -830,19 +830,19 @@ impl Bank {
return Err(err); return Err(err);
} }
} else if budget_program::check_id(&program_id) { } else if budget_program::check_id(&program_id) {
if budget_program::process_transaction(&tx, instruction_index, program_accounts) if budget_program::process_instruction(&tx, instruction_index, program_accounts)
.is_err() .is_err()
{ {
return Err(BankError::ProgramRuntimeError(instruction_index as u8)); return Err(BankError::ProgramRuntimeError(instruction_index as u8));
} }
} else if storage_program::check_id(&program_id) { } else if storage_program::check_id(&program_id) {
if storage_program::process_transaction(&tx, instruction_index, program_accounts) if storage_program::process_instruction(&tx, instruction_index, program_accounts)
.is_err() .is_err()
{ {
return Err(BankError::ProgramRuntimeError(instruction_index as u8)); return Err(BankError::ProgramRuntimeError(instruction_index as u8));
} }
} else if vote_program::check_id(&program_id) { } else if vote_program::check_id(&program_id) {
if vote_program::process_transaction(&tx, instruction_index, program_accounts).is_err() if vote_program::process_instruction(&tx, instruction_index, program_accounts).is_err()
{ {
return Err(BankError::ProgramRuntimeError(instruction_index as u8)); return Err(BankError::ProgramRuntimeError(instruction_index as u8));
} }

View File

@ -116,13 +116,13 @@ fn apply_debits(
/// * accounts[0] - The source of the tokens /// * accounts[0] - The source of the tokens
/// * accounts[1] - The contract context. Once the contract has been completed, the tokens can /// * accounts[1] - The contract context. Once the contract has been completed, the tokens can
/// be spent from this account . /// be spent from this account .
pub fn process_transaction( pub fn process_instruction(
tx: &Transaction, tx: &Transaction,
instruction_index: usize, instruction_index: usize,
accounts: &mut [&mut Account], accounts: &mut [&mut Account],
) -> Result<(), BudgetError> { ) -> Result<(), BudgetError> {
if let Ok(instruction) = deserialize(tx.userdata(instruction_index)) { if let Ok(instruction) = deserialize(tx.userdata(instruction_index)) {
trace!("process_transaction: {:?}", instruction); trace!("process_instruction: {:?}", instruction);
apply_debits(tx, instruction_index, accounts, &instruction) apply_debits(tx, instruction_index, accounts, &instruction)
} else { } else {
info!( info!(
@ -264,7 +264,7 @@ mod test {
fn process_transaction(tx: &Transaction, accounts: &mut [Account]) -> Result<(), BudgetError> { fn process_transaction(tx: &Transaction, accounts: &mut [Account]) -> Result<(), BudgetError> {
let mut refs: Vec<&mut Account> = accounts.iter_mut().collect(); let mut refs: Vec<&mut Account> = accounts.iter_mut().collect();
super::process_transaction(&tx, 0, &mut refs[..]) super::process_instruction(&tx, 0, &mut refs[..])
} }
#[test] #[test]
fn test_serializer() { fn test_serializer() {

View File

@ -34,7 +34,7 @@ pub fn get_balance(account: &Account) -> u64 {
account.tokens account.tokens
} }
pub fn process_transaction( pub fn process_instruction(
tx: &Transaction, tx: &Transaction,
pix: usize, pix: usize,
_accounts: &mut [&mut Account], _accounts: &mut [&mut Account],
@ -61,6 +61,6 @@ mod test {
fn test_storage_tx() { fn test_storage_tx() {
let keypair = Keypair::new(); let keypair = Keypair::new();
let tx = Transaction::new(&keypair, &[], id(), &(), Default::default(), 0); let tx = Transaction::new(&keypair, &[], id(), &(), Default::default(), 0);
assert!(process_transaction(&tx, 0, &mut []).is_err()); assert!(process_instruction(&tx, 0, &mut []).is_err());
} }
} }

View File

@ -35,13 +35,13 @@ pub fn id() -> Pubkey {
pub fn get_balance(account: &Account) -> u64 { pub fn get_balance(account: &Account) -> u64 {
account.tokens account.tokens
} }
pub fn process_transaction( pub fn process_instruction(
tx: &Transaction, tx: &Transaction,
pix: usize, pix: usize,
accounts: &mut [&mut Account], accounts: &mut [&mut Account],
) -> Result<()> { ) -> Result<()> {
if let Ok(syscall) = deserialize(tx.userdata(pix)) { if let Ok(syscall) = deserialize(tx.userdata(pix)) {
trace!("process_transaction: {:?}", syscall); trace!("process_instruction: {:?}", syscall);
match syscall { match syscall {
SystemInstruction::CreateAccount { SystemInstruction::CreateAccount {
tokens, tokens,
@ -111,7 +111,7 @@ mod test {
fn process_transaction(tx: &Transaction, accounts: &mut [Account]) -> Result<()> { fn process_transaction(tx: &Transaction, accounts: &mut [Account]) -> Result<()> {
let mut refs: Vec<&mut Account> = accounts.iter_mut().collect(); let mut refs: Vec<&mut Account> = accounts.iter_mut().collect();
super::process_transaction(&tx, 0, &mut refs[..]) super::process_instruction(&tx, 0, &mut refs[..])
} }
#[test] #[test]

View File

@ -64,7 +64,7 @@ pub fn id() -> Pubkey {
Pubkey::new(&VOTE_PROGRAM_ID) Pubkey::new(&VOTE_PROGRAM_ID)
} }
pub fn process_transaction( pub fn process_instruction(
tx: &Transaction, tx: &Transaction,
instruction_index: usize, instruction_index: usize,
accounts: &mut [&mut Account], accounts: &mut [&mut Account],