From a75fa97f56013769289a56607dee78d85546e8a1 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 20 Aug 2025 14:51:32 +0800 Subject: [PATCH] core, trie: use db.has over db.get where possible #24117 (#1078) --- trie/sync.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trie/sync.go b/trie/sync.go index 80c69f9cce..d67d82b48a 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -156,8 +156,7 @@ func (s *Sync) AddSubTrie(root common.Hash, path []byte, parent common.Hash, cal } // If database says this is a duplicate, then at least the trie node is // present, and we hold the assumption that it's NOT legacy contract code. - blob := rawdb.ReadTrieNode(s.database, root) - if len(blob) > 0 { + if rawdb.HasTrieNode(s.database, root) { return } // Assemble the new sub-trie sync request @@ -194,7 +193,7 @@ func (s *Sync) AddCodeEntry(hash common.Hash, path []byte, parent common.Hash) { // sync is expected to run with a fresh new node. Even there // exists the code with legacy format, fetch and store with // new scheme anyway. - if blob := rawdb.ReadCodeWithPrefix(s.database, hash); len(blob) > 0 { + if rawdb.HasCodeWithPrefix(s.database, hash) { return } // Assemble the new sub-trie sync request @@ -402,7 +401,7 @@ func (s *Sync) children(req *request, object node) ([]*request, error) { } // If database says duplicate, then at least the trie node is present // and we hold the assumption that it's NOT legacy contract code. - if blob := rawdb.ReadTrieNode(s.database, hash); len(blob) > 0 { + if rawdb.HasTrieNode(s.database, hash) { continue } // Locally unknown Node, schedule for retrieval