Skip to content

Commit

Permalink
use new_from_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Mar 20, 2024
1 parent 2655981 commit 42bb424
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
9 changes: 3 additions & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7788,13 +7788,10 @@ impl Bank {
}

pub fn new_program_cache_for_tx_batch_for_slot(&self, slot: Slot) -> LoadedProgramsForTxBatch {
let program_cache_r = self.program_cache.read().unwrap();
let epoch = self.epoch_schedule.get_epoch(slot);
LoadedProgramsForTxBatch::new(
LoadedProgramsForTxBatch::new_from_cache(
slot,
program_cache_r.get_environments_for_epoch(epoch).clone(),
program_cache_r.get_upcoming_environments_for_epoch(epoch),
program_cache_r.latest_root_epoch,
self.epoch_schedule.get_epoch(slot),
&self.program_cache.read().unwrap(),
)
}
}
Expand Down
14 changes: 6 additions & 8 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,10 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
// Initialize our local cache.
let is_first_round = loaded_programs_for_txs.is_none();
if is_first_round {
loaded_programs_for_txs = Some(LoadedProgramsForTxBatch::new(
loaded_programs_for_txs = Some(LoadedProgramsForTxBatch::new_from_cache(
self.slot,
program_cache.get_environments_for_epoch(self.epoch).clone(),
program_cache.get_upcoming_environments_for_epoch(self.epoch),
program_cache.latest_root_epoch,
self.epoch,
&program_cache,
));
}
// Submit our last completed loading task.
Expand All @@ -522,11 +521,10 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
// This branch is taken when there is an error in assigning a program to a
// cache slot. It is not possible to mock this error for SVM unit
// tests purposes.
let mut ret = LoadedProgramsForTxBatch::new(
let mut ret = LoadedProgramsForTxBatch::new_from_cache(
self.slot,
program_cache.get_environments_for_epoch(self.epoch).clone(),
program_cache.get_upcoming_environments_for_epoch(self.epoch),
program_cache.latest_root_epoch,
self.epoch,
&program_cache,
);
ret.hit_max_limit = true;
return ret;
Expand Down

0 comments on commit 42bb424

Please sign in to comment.