Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
trie: fix regression that linked all downloaded nodes together
Browse files Browse the repository at this point in the history
The trie sync code links subtries using pointers into node structs.
Since commit 40cdcf1 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.
  • Loading branch information
fjl committed Oct 14, 2016
1 parent 81b01f1 commit 2cd7a03
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions trie/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 2cd7a03

Please sign in to comment.