mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
This commit is contained in:
parent
7464f0a7f3
commit
cd407af1aa
1 changed files with 13 additions and 1 deletions
|
|
@ -47,7 +47,7 @@ func ReadCode(db ethdb.KeyValueReader, hash common.Hash) []byte {
|
||||||
if len(data) != 0 {
|
if len(data) != 0 {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
data, _ = db.Get(hash[:])
|
data, _ = db.Get(hash.Bytes())
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +59,18 @@ func ReadCodeWithPrefix(db ethdb.KeyValueReader, hash common.Hash) []byte {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasCode checks if the contract code corresponding to the
|
||||||
|
// provided code hash is present in the db.
|
||||||
|
func HasCode(db ethdb.KeyValueReader, hash common.Hash) bool {
|
||||||
|
// Try with the prefixed code scheme first, if not then try with legacy
|
||||||
|
// scheme.
|
||||||
|
if ok := HasCodeWithPrefix(db, hash); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
ok, _ := db.Has(hash.Bytes())
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// HasCodeWithPrefix checks if the contract code corresponding to the
|
// HasCodeWithPrefix checks if the contract code corresponding to the
|
||||||
// provided code hash is present in the db. This function will only check
|
// provided code hash is present in the db. This function will only check
|
||||||
// presence using the prefix-scheme.
|
// presence using the prefix-scheme.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue