Skip to content

Commit

Permalink
core/rawdb: do prefixed lookup first
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Jan 25, 2022
1 parent f9ce40b commit 0e35192
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/rawdb/accessors_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ func WritePreimages(db ethdb.KeyValueWriter, preimages map[common.Hash][]byte) {

// ReadCode retrieves the contract code of the provided code hash.
func ReadCode(db ethdb.KeyValueReader, hash common.Hash) []byte {
// Try with the legacy code scheme first, if not then try with current
// scheme. Since most of the code will be found with legacy scheme.
//
// todo(rjl493456442) change the order when we forcibly upgrade the code
// scheme with snapshot.
data, _ := db.Get(hash[:])
// Try with the prefixed code scheme first, if not then try with legacy
// scheme.
data := ReadCodeWithPrefix(db, hash)
if len(data) != 0 {
return data
}
return ReadCodeWithPrefix(db, hash)
data, _ := db.Get(hash[:])
return data
}

// ReadCodeWithPrefix retrieves the contract code of the provided code hash.
Expand Down

0 comments on commit 0e35192

Please sign in to comment.