[release/1.4.6] core, core/state, trie: enterprise hand-tuned multi-level caching

(cherry picked from commit 748d1c171d)
This commit is contained in:
Péter Szilágyi
2016-05-19 13:24:14 +03:00
parent 7632acf6b4
commit af53767e16
9 changed files with 245 additions and 134 deletions

View File

@ -75,8 +75,9 @@ func (s *TrieSync) AddSubTrie(root common.Hash, depth int, parent common.Hash, c
if root == emptyRoot {
return
}
blob, _ := s.database.Get(root.Bytes())
if local, err := decodeNode(blob); local != nil && err == nil {
key := root.Bytes()
blob, _ := s.database.Get(key)
if local, err := decodeNode(key, blob); local != nil && err == nil {
return
}
// Assemble the new sub-trie sync request
@ -152,7 +153,7 @@ func (s *TrieSync) Process(results []SyncResult) (int, error) {
continue
}
// Decode the node data content and update the request
node, err := decodeNode(item.Data)
node, err := decodeNode(item.Hash[:], item.Data)
if err != nil {
return i, err
}
@ -213,9 +214,9 @@ func (s *TrieSync) children(req *request) ([]*request, error) {
}}
case fullNode:
for i := 0; i < 17; i++ {
if node[i] != nil {
if node.Children[i] != nil {
children = append(children, child{
node: &node[i],
node: &node.Children[i],
depth: req.depth + 1,
})
}
@ -238,7 +239,7 @@ func (s *TrieSync) children(req *request) ([]*request, error) {
if node, ok := (*child.node).(hashNode); ok {
// Try to resolve the node from the local database
blob, _ := s.database.Get(node)
if local, err := decodeNode(blob); local != nil && err == nil {
if local, err := decodeNode(node[:], blob); local != nil && err == nil {
*child.node = local
continue
}