diff options
author | Felix Lange <fjl@twurst.com> | 2016-10-15 06:40:32 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-10-15 06:42:52 +0800 |
commit | 2cd7a0395dd8813867884bced1b01663165ea1d4 (patch) | |
tree | fb1d5bab651dab23e6280327ff22f8c2094a65b2 /trie/sync.go | |
parent | 81b01f1c2bba8340f9cf2bf1da8ef131e3decd50 (diff) | |
download | go-tangerine-2cd7a0395dd8813867884bced1b01663165ea1d4.tar.gz go-tangerine-2cd7a0395dd8813867884bced1b01663165ea1d4.tar.zst go-tangerine-2cd7a0395dd8813867884bced1b01663165ea1d4.zip |
trie: fix regression that linked all downloaded nodes together
The trie sync code links subtries using pointers into node structs.
Since commit 40cdcf1183 nodes are no longer copied when unpacking from
an interface value, causing all nodes to get linked up as the sync
progresses. Fix it by breaking the pointer chain with an explicit copy.
Diffstat (limited to 'trie/sync.go')
-rw-r--r-- | trie/sync.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/trie/sync.go b/trie/sync.go index 3de758536..400dff903 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -213,11 +213,13 @@ func (s *TrieSync) children(req *request) ([]*request, error) { switch node := (*req.object).(type) { case *shortNode: + node = node.copy() // Prevents linking all downloaded nodes together. children = []child{{ node: &node.Val, depth: req.depth + len(node.Key), }} case *fullNode: + node = node.copy() for i := 0; i < 17; i++ { if node.Children[i] != nil { children = append(children, child{ |