Skip to content

Commit 2cd7a03

Browse files
committed
trie: fix regression that linked all downloaded nodes together
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.
1 parent 81b01f1 commit 2cd7a03

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎trie/sync.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ func (s *TrieSync) children(req *request) ([]*request, error) {
213213

214214
switch node := (*req.object).(type) {
215215
case *shortNode:
216+
node = node.copy() // Prevents linking all downloaded nodes together.
216217
children = []child{{
217218
node: &node.Val,
218219
depth: req.depth + len(node.Key),
219220
}}
220221
case *fullNode:
222+
node = node.copy()
221223
for i := 0; i < 17; i++ {
222224
if node.Children[i] != nil {
223225
children = append(children, child{

0 commit comments

Comments
 (0)