Skip to content

Commit

Permalink
fix: support code getters for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Sep 20, 2023
1 parent 5d5f0b2 commit 72209a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,13 @@ impl<T: Config> Pallet<T> {
/// Get the account metadata (hash and size) from storage if it exists,
/// or compute it from code and store it if it doesn't exist.
pub fn account_code_metadata(address: H160) -> CodeMetadata {
if let Some(code) = <T as Config>::OnMethodCall::get_code(&address) {
return CodeMetadata {
size: code.len() as u64,
// TODO: Store code hash in OnMethodCall
hash: H256::from(sp_io::hashing::keccak_256(&code)),
};
}
if let Some(meta) = <AccountCodesMetadata<T>>::get(address) {
return meta;
}
Expand Down

0 comments on commit 72209a4

Please sign in to comment.