Ver Fonte

fix cache key do not have hash func (#455)

Signed-off-by: kyrie-yl <yl.on.the.way@gmail.com>
kyrie-yl há 4 anos atrás
pai
commit
aecb61296d
1 ficheiros alterados com 2 adições e 2 exclusões
  1. 2 2
      core/state/database.go

+ 2 - 2
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
 	}