core, core/state, trie: enterprise hand-tuned multi-level caching

This commit is contained in:
Péter Szilágyi
2016-05-19 13:24:14 +03:00
parent a7434fd008
commit 748d1c171d
9 changed files with 245 additions and 134 deletions

View File

@ -54,7 +54,7 @@ func (t *Trie) Prove(key []byte) []rlp.RawValue {
}
nodes = append(nodes, n)
case fullNode:
tn = n[key[0]]
tn = n.Children[key[0]]
key = key[1:]
nodes = append(nodes, n)
case hashNode:
@ -77,7 +77,7 @@ func (t *Trie) Prove(key []byte) []rlp.RawValue {
for i, n := range nodes {
// Don't bother checking for errors here since hasher panics
// if encoding doesn't work and we're not writing to any database.
n, _ = t.hasher.replaceChildren(n, nil)
n, _, _ = t.hasher.hashChildren(n, nil)
hn, _ := t.hasher.store(n, nil, false)
if _, ok := hn.(hashNode); ok || i == 0 {
// If the node's database encoding is a hash (or is the
@ -103,7 +103,7 @@ func VerifyProof(rootHash common.Hash, key []byte, proof []rlp.RawValue) (value
if !bytes.Equal(sha.Sum(nil), wantHash) {
return nil, fmt.Errorf("bad proof node %d: hash mismatch", i)
}
n, err := decodeNode(buf)
n, err := decodeNode(wantHash, buf)
if err != nil {
return nil, fmt.Errorf("bad proof node %d: %v", i, err)
}
@ -139,7 +139,7 @@ func get(tn node, key []byte) ([]byte, node) {
tn = n.Val
key = key[len(n.Key):]
case fullNode:
tn = n[key[0]]
tn = n.Children[key[0]]
key = key[1:]
case hashNode:
return key, n