diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-05-19 18:24:14 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-05-26 21:33:09 +0800 |
commit | 748d1c171d74fbf6b6051fd629d3c2204dd930e3 (patch) | |
tree | f3bc5352efadae61cb39afd33ceeaba7b824609c /trie/sync.go | |
parent | a7434fd0085f55235acea5348db0c9247e9aac10 (diff) | |
download | go-tangerine-748d1c171d74fbf6b6051fd629d3c2204dd930e3.tar.gz go-tangerine-748d1c171d74fbf6b6051fd629d3c2204dd930e3.tar.zst go-tangerine-748d1c171d74fbf6b6051fd629d3c2204dd930e3.zip |
core, core/state, trie: enterprise hand-tuned multi-level caching
Diffstat (limited to 'trie/sync.go')
-rw-r--r-- | trie/sync.go | 13 |
1 files changed, 7 insertions, 6 deletions
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 } |