aboutsummaryrefslogtreecommitdiffstats
path: root/trie/sync.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-17 22:13:50 +0800
committerFelix Lange <fjl@twurst.com>2016-10-18 10:57:47 +0800
commit177cab5fe70910ee0af3fcf493d51999ae2d923d (patch)
tree54a8c78b9e2a25880b1d9cc284affad7d0830d33 /trie/sync.go
parent187d6a66a5176a1dc3e75d5ad4baad623762acb9 (diff)
downloaddexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar.gz
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar.bz2
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar.lz
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar.xz
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.tar.zst
dexon-177cab5fe70910ee0af3fcf493d51999ae2d923d.zip
trie: ensure resolved nodes stay loaded
Commit 40cdcf1183 broke the optimisation which kept nodes resolved during Get in the trie. The decoder assigned cache generation 0 unconditionally, causing resolved nodes to get flushed on Commit. This commit fixes it and adds two tests.
Diffstat (limited to 'trie/sync.go')
-rw-r--r--trie/sync.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/trie/sync.go b/trie/sync.go
index 400dff903..30caf6980 100644
--- a/trie/sync.go
+++ b/trie/sync.go
@@ -82,7 +82,7 @@ func (s *TrieSync) AddSubTrie(root common.Hash, depth int, parent common.Hash, c
}
key := root.Bytes()
blob, _ := s.database.Get(key)
- if local, err := decodeNode(key, blob); local != nil && err == nil {
+ if local, err := decodeNode(key, blob, 0); local != nil && err == nil {
return
}
// Assemble the new sub-trie sync request
@@ -158,7 +158,7 @@ func (s *TrieSync) Process(results []SyncResult) (int, error) {
continue
}
// Decode the node data content and update the request
- node, err := decodeNode(item.Hash[:], item.Data)
+ node, err := decodeNode(item.Hash[:], item.Data, 0)
if err != nil {
return i, err
}
@@ -246,7 +246,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(node[:], blob); local != nil && err == nil {
+ if local, err := decodeNode(node[:], blob, 0); local != nil && err == nil {
*child.node = local
continue
}