Skip to content

Commit 18c8ded

Browse files
fjlkaralabe
authored andcommitted
[release/1.4.18] 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. (cherry picked from commit 2cd7a03)
1 parent 00ba748 commit 18c8ded

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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)