From 748d1c171d74fbf6b6051fd629d3c2204dd930e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 19 May 2016 13:24:14 +0300 Subject: core, core/state, trie: enterprise hand-tuned multi-level caching --- trie/sync.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'trie/sync.go') diff --git a/trie/sync.go b/trie/sync.go index d55399d06..a35478f83 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -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 } -- cgit v1.2.3