From 6c7534337cbc7426178868f097a08f8b27153675 Mon Sep 17 00:00:00 2001 From: Harry Ngo <17699212+huyngopt1994@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:57:27 +0700 Subject: [PATCH] eth/protocols/snap: fix batch writer when resuming an aborted sync (#27842) (#587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Péter Szilágyi --- eth/protocols/snap/sync.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/protocols/snap/sync.go b/eth/protocols/snap/sync.go index d04358ebf..c4b0a25dd 100644 --- a/eth/protocols/snap/sync.go +++ b/eth/protocols/snap/sync.go @@ -714,6 +714,8 @@ func (s *Syncer) loadSyncStatus() { } s.tasks = progress.Tasks for _, task := range s.tasks { + task := task // closure for task.genBatch in the stacktrie writer callback + task.genBatch = ethdb.HookedBatch{ Batch: s.db.NewBatch(), OnPut: func(key []byte, value []byte) { @@ -726,6 +728,8 @@ func (s *Syncer) loadSyncStatus() { for accountHash, subtasks := range task.SubTasks { for _, subtask := range subtasks { + subtask := subtask // closure for subtask.genBatch in the stacktrie writer callback + subtask.genBatch = ethdb.HookedBatch{ Batch: s.db.NewBatch(), OnPut: func(key []byte, value []byte) {