Unverified Commit 6e934f40 authored by Péter Szilágyi's avatar Péter Szilágyi Committed by GitHub

eth/protocols/snap: fix batch writer when resuming an aborted sync (#27842)

parent 8224bb92
...@@ -730,6 +730,8 @@ func (s *Syncer) loadSyncStatus() { ...@@ -730,6 +730,8 @@ func (s *Syncer) loadSyncStatus() {
} }
s.tasks = progress.Tasks s.tasks = progress.Tasks
for _, task := range s.tasks { for _, task := range s.tasks {
task := task // closure for task.genBatch in the stacktrie writer callback
task.genBatch = ethdb.HookedBatch{ task.genBatch = ethdb.HookedBatch{
Batch: s.db.NewBatch(), Batch: s.db.NewBatch(),
OnPut: func(key []byte, value []byte) { OnPut: func(key []byte, value []byte) {
...@@ -741,6 +743,8 @@ func (s *Syncer) loadSyncStatus() { ...@@ -741,6 +743,8 @@ func (s *Syncer) loadSyncStatus() {
}) })
for accountHash, subtasks := range task.SubTasks { for accountHash, subtasks := range task.SubTasks {
for _, subtask := range subtasks { for _, subtask := range subtasks {
subtask := subtask // closure for subtask.genBatch in the stacktrie writer callback
subtask.genBatch = ethdb.HookedBatch{ subtask.genBatch = ethdb.HookedBatch{
Batch: s.db.NewBatch(), Batch: s.db.NewBatch(),
OnPut: func(key []byte, value []byte) { OnPut: func(key []byte, value []byte) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment