mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
Merge c7c2e8e990 into 3778f1bf77
This commit is contained in:
commit
e7bd602cbd
1 changed files with 10 additions and 9 deletions
19
trie/trie.go
19
trie/trie.go
|
|
@ -410,11 +410,16 @@ func (t *Trie) resolve(n node, prefix, suffix []byte) (node, error) {
|
|||
}
|
||||
|
||||
func (t *Trie) resolveHash(n hashNode, prefix, suffix []byte) (node, error) {
|
||||
if v, ok := globalCache.Get(n); ok {
|
||||
return v, nil
|
||||
}
|
||||
var v node = nil
|
||||
var ok bool
|
||||
if v, ok = globalCache.Get(n); !ok {
|
||||
enc, err := t.db.Get(n)
|
||||
if err != nil || enc == nil {
|
||||
if err == nil && enc != nil {
|
||||
v = mustDecodeNode(n, enc)
|
||||
}
|
||||
globalCache.Put(n, v)
|
||||
}
|
||||
if v == nil {
|
||||
return nil, &MissingNodeError{
|
||||
RootHash: t.originalRoot,
|
||||
NodeHash: common.BytesToHash(n),
|
||||
|
|
@ -423,11 +428,7 @@ func (t *Trie) resolveHash(n hashNode, prefix, suffix []byte) (node, error) {
|
|||
SuffixLen: len(suffix),
|
||||
}
|
||||
}
|
||||
dec := mustDecodeNode(n, enc)
|
||||
if dec != nil {
|
||||
globalCache.Put(n, dec)
|
||||
}
|
||||
return dec, nil
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Root returns the root hash of the trie.
|
||||
|
|
|
|||
Loading…
Reference in a new issue