From 34456c954c2479079ca92aa2e412becd6327a153 Mon Sep 17 00:00:00 2001 From: guagualvcha <296179868@qq.com> Date: Fri, 15 Oct 2021 16:57:47 +0800 Subject: [PATCH] fix cache key --- core/state/database.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/state/database.go b/core/state/database.go index 24a1474d57..1c18c282e7 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -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 @@ -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 } @@ -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 } }