Skip to content

Commit f272ce1

Browse files
authored
core/rawdb: add func HasCodeWithPrefix and HasTrieNode ethereum#24117 (#1210)
1 parent 9a50df0 commit f272ce1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/rawdb/accessors_state.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ func ReadCodeWithPrefix(db ethdb.KeyValueReader, hash common.Hash) []byte {
5959
return data
6060
}
6161

62+
// HasCodeWithPrefix checks if the contract code corresponding to the
63+
// provided code hash is present in the db. This function will only check
64+
// presence using the prefix-scheme.
65+
func HasCodeWithPrefix(db ethdb.KeyValueReader, hash common.Hash) bool {
66+
ok, _ := db.Has(codeKey(hash))
67+
return ok
68+
}
69+
6270
// WriteCode writes the provided contract code database.
6371
func WriteCode(db ethdb.KeyValueWriter, hash common.Hash, code []byte) {
6472
if err := db.Put(codeKey(hash), code); err != nil {
@@ -79,6 +87,12 @@ func ReadTrieNode(db ethdb.KeyValueReader, hash common.Hash) []byte {
7987
return data
8088
}
8189

90+
// HasTrieNode checks if the trie node with the provided hash is present in db.
91+
func HasTrieNode(db ethdb.KeyValueReader, hash common.Hash) bool {
92+
ok, _ := db.Has(hash.Bytes())
93+
return ok
94+
}
95+
8296
// WriteTrieNode writes the provided trie node database.
8397
func WriteTrieNode(db ethdb.KeyValueWriter, hash common.Hash, node []byte) {
8498
if err := db.Put(hash.Bytes(), node); err != nil {

0 commit comments

Comments
 (0)