From aecb61296d928474b94511d614f8b5a47ae907de Mon Sep 17 00:00:00 2001 From: kyrie-yl <83150977+kyrie-yl@users.noreply.github.com> Date: Fri, 15 Oct 2021 18:10:58 +0800 Subject: [PATCH] fix cache key do not have hash func (#455) Signed-off-by: kyrie-yl --- core/state/database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/state/database.go b/core/state/database.go index 1c18c282e7..b65dfca158 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -287,7 +287,7 @@ func (db *cachingDB) ContractCode(addrHash, codeHash common.Hash) ([]byte, error // code can't be found in the cache, then check the existence with **new** // db scheme. func (db *cachingDB) ContractCodeWithPrefix(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 @@ -295,7 +295,7 @@ func (db *cachingDB) ContractCodeWithPrefix(addrHash, codeHash common.Hash) ([]b } code := rawdb.ReadCodeWithPrefix(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 }