Skip to content

Commit

Permalink
core/state: implement GetCodeSize for VerkleDB (ethereum#75)
Browse files Browse the repository at this point in the history
implement core/state: implement GetCodeSize for VerkleDB
  • Loading branch information
jwasinger authored Feb 7, 2022
1 parent 825884a commit a758e16
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,16 @@ func (db *VerkleDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error)

// ContractCodeSize retrieves a particular contracts code's size.
func (db *VerkleDB) ContractCodeSize(addrHash, codeHash common.Hash) (int, error) {
panic("need to merge #31 for this to work")
if code := db.codeCache.Get(nil, codeHash.Bytes()); len(code) > 0 {
return len(code), nil
}
code := rawdb.ReadCode(db.db.DiskDB(), codeHash)
if len(code) > 0 {
db.codeCache.Set(codeHash.Bytes(), code)
db.codeSizeCache.Add(codeHash, len(code))
return len(code), nil
}
return 0, nil
}

// TrieDB retrieves the low level trie database used for data storage.
Expand Down

0 comments on commit a758e16

Please sign in to comment.