mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
trie: optimize local node check
This commit is contained in:
parent
52e7b2a9c8
commit
8e93c3e7a3
2 changed files with 3 additions and 3 deletions
|
|
@ -138,7 +138,7 @@ func (s *TrieSync) AddRawEntry(hash common.Hash, depth int, parent common.Hash)
|
|||
if _, ok := s.membatch.batch[hash]; ok {
|
||||
return
|
||||
}
|
||||
if blob, _ := s.database.Get(hash.Bytes()); blob != nil {
|
||||
if ok, _ := s.database.Has(hash.Bytes()); ok {
|
||||
return
|
||||
}
|
||||
// Assemble the new sub-trie sync request
|
||||
|
|
@ -296,8 +296,7 @@ func (s *TrieSync) children(req *request, object node) ([]*request, error) {
|
|||
if _, ok := s.membatch.batch[hash]; ok {
|
||||
continue
|
||||
}
|
||||
blob, _ := s.database.Get(node)
|
||||
if local, err := decodeNode(node[:], blob, 0); local != nil && err == nil {
|
||||
if ok, _ := s.database.Has(node); ok {
|
||||
continue
|
||||
}
|
||||
// Locally unknown node, schedule for retrieval
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ type Database interface {
|
|||
// DatabaseReader wraps the Get method of a backing store for the trie.
|
||||
type DatabaseReader interface {
|
||||
Get(key []byte) (value []byte, err error)
|
||||
Has(key []byte) (bool, error)
|
||||
}
|
||||
|
||||
// DatabaseWriter wraps the Put method of a backing store for the trie.
|
||||
|
|
|
|||
Loading…
Reference in a new issue