Skip to content

Commit

Permalink
fix cache key (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro authored Oct 15, 2021
1 parent 31463f8 commit 8f605f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (db *cachingDB) CopyTrie(t Trie) Trie {

// ContractCode retrieves a particular contract's code.
func (db *cachingDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error) {
if cached, ok := db.codeCache.Get(codeHash.Bytes()); ok {
if cached, ok := db.codeCache.Get(codeHash); ok {
code := cached.([]byte)
if len(code) > 0 {
return code, nil
Expand All @@ -276,7 +276,7 @@ func (db *cachingDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error
code := rawdb.ReadCode(db.db.DiskDB(), codeHash)
if len(code) > 0 {

db.codeCache.Add(codeHash.Bytes(), code)
db.codeCache.Add(codeHash, code)
db.codeSizeCache.Add(codeHash, len(code))
return code, nil
}
Expand All @@ -289,7 +289,7 @@ func (db *cachingDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error
func (db *cachingDB) ContractCodeWithPrefix(addrHash, codeHash common.Hash) ([]byte, error) {
if cached, ok := db.codeCache.Get(codeHash.Bytes()); ok {
code := cached.([]byte)
if len(code) > 0 {
if len(code) > 0 {
return code, nil
}
}
Expand Down

0 comments on commit 8f605f5

Please sign in to comment.