Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Hoist load_loaders()
Browse files Browse the repository at this point in the history
This makes execute_transactions() stateless.
  • Loading branch information
garious committed Nov 27, 2018
1 parent ffd4426 commit d2e55fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,11 @@ impl Bank {
/// This method calls each instruction in the transaction over the set of loaded Accounts
/// The accounts are committed back to the bank only if every instruction succeeds
fn execute_transaction(
&self,
tx: &Transaction,
loaders: &mut [Vec<(Pubkey, Account)>],
tx_accounts: &mut [Account],
tick_height: u64,
) -> Result<()> {
let mut loaders = self.load_loaders(tx)?;
for (instruction_index, instruction) in tx.instructions.iter().enumerate() {
let ref mut executable_accounts = &mut loaders[instruction.program_ids_index as usize];
Self::with_subset(tx_accounts, &instruction.accounts, |program_accounts| {
Expand Down Expand Up @@ -902,7 +901,10 @@ impl Bank {
.zip(txs.iter())
.map(|(acc, tx)| match acc {
Err(e) => Err(e.clone()),
Ok(ref mut accounts) => self.execute_transaction(tx, accounts, tick_height),
Ok(ref mut accounts) => {
let mut loaders = self.load_loaders(tx)?;
Self::execute_transaction(tx, &mut loaders, accounts, tick_height)
}
}).collect();
let execution_elapsed = now.elapsed();
let now = Instant::now();
Expand Down

0 comments on commit d2e55fb

Please sign in to comment.