Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay committed Jan 6, 2022
1 parent f8c5595 commit 7f345bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,19 +397,18 @@ impl CachedExecutors {
executors: HashMap::new(),
}
}

fn get(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
self.executors.get(pubkey).map(|entry| {
entry.epoch_count.fetch_add(1, Relaxed);
entry.executor.clone()
})
}

fn put(&mut self, pubkey: &Pubkey, executor: Arc<dyn Executor>) {
let entry = if let Some(entry) = self.executors.get(pubkey) {
CachedExecutorsEntry {
prev_epoch_count: entry.prev_epoch_count,
epoch_count: AtomicU64::new(entry.epoch_count.load(Relaxed)),
executor,
}
let entry = if let Some(mut entry) = self.executors.remove(pubkey) {
entry.executor = executor;
entry
} else {
if self.executors.len() >= self.max {
let mut least = u64::MAX;
Expand All @@ -434,6 +433,7 @@ impl CachedExecutors {
};
let _ = self.executors.insert(*pubkey, entry);
}

fn remove(&mut self, pubkey: &Pubkey) {
let _ = self.executors.remove(pubkey);
}
Expand Down

0 comments on commit 7f345bd

Please sign in to comment.