Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
small review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro committed Feb 15, 2024
1 parent 2f91394 commit da29519
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/blockifier/src/state/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub type ContractClassMapping = HashMap<ClassHash, ContractClass>;
pub struct CachedState<S: StateReader> {
pub state: S,
// Invariant: read/write access is managed by CachedState.
// Using interior mutability to update caches during `State`'s immutable getters.
cache: RefCell<StateCache>,
class_hash_to_class: RefCell<ContractClassMapping>,
// Invariant: managed by CachedState.
Expand Down Expand Up @@ -215,18 +216,19 @@ impl<S: StateReader> StateReader for CachedState<S> {
fn get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult<ContractClass> {
let class_hash_to_class = &mut *self.class_hash_to_class.borrow_mut();

if let std::collections::hash_map::Entry::Vacant(e) = class_hash_to_class.entry(class_hash)
if let std::collections::hash_map::Entry::Vacant(vacant_entry) =
class_hash_to_class.entry(class_hash)
{
let contract_class = self.global_class_hash_to_class().cache_get(&class_hash).cloned();

match contract_class {
Some(contract_class_from_global_cache) => {
e.insert(contract_class_from_global_cache);
vacant_entry.insert(contract_class_from_global_cache);
}
None => {
let contract_class_from_db =
self.state.get_compiled_contract_class(class_hash)?;
e.insert(contract_class_from_db);
vacant_entry.insert(contract_class_from_db);
}
}
}
Expand Down

0 comments on commit da29519

Please sign in to comment.