From 6e934f40f9a7edd58107725d9d766770bc128775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 3 Aug 2023 14:51:02 +0300 Subject: [PATCH] eth/protocols/snap: fix batch writer when resuming an aborted sync (#27842) --- 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 49c43563d..0f5f2ccdf 100644 --- a/eth/protocols/snap/sync.go +++ b/eth/protocols/snap/sync.go @@ -730,6 +730,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) { @@ -741,6 +743,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) {