Skip to content

Commit

Permalink
eth/protocols/snap: address review concerns (add comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Oct 10, 2023
1 parent 209d4e2 commit 18771a7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions eth/protocols/snap/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func (s *Syncer) loadSyncStatus() {
s.storageBytes += common.StorageSize(len(key) + len(value))
},
}
owner := accountHash
owner := accountHash // local assignment for stacktrie writer closure
subtask.genTrie = trie.NewStackTrie(func(path []byte, hash common.Hash, val []byte) {
rawdb.WriteTrieNode(subtask.genBatch, owner, path, hash, val, s.scheme)
})
Expand Down Expand Up @@ -2005,7 +2005,7 @@ func (s *Syncer) processStorageResponse(res *storageResponse) {
s.storageBytes += common.StorageSize(len(key) + len(value))
},
}
owner := account
owner := account // local assignment for stacktrie writer closure
tasks = append(tasks, &storageTask{
Next: common.Hash{},
Last: r.End(),
Expand All @@ -2022,7 +2022,6 @@ func (s *Syncer) processStorageResponse(res *storageResponse) {
s.storageBytes += common.StorageSize(len(key) + len(value))
},
}
owner := account
tasks = append(tasks, &storageTask{
Next: r.Start(),
Last: r.End(),
Expand Down Expand Up @@ -2075,9 +2074,9 @@ func (s *Syncer) processStorageResponse(res *storageResponse) {
slots += len(res.hashes[i])

if i < len(res.hashes)-1 || res.subTask == nil {
owner := account
// no need to make local reassignment of account: this closure does not outlive the loop
tr := trie.NewStackTrie(func(path []byte, hash common.Hash, val []byte) {
rawdb.WriteTrieNode(batch, owner, path, hash, val, s.scheme)
rawdb.WriteTrieNode(batch, account, path, hash, val, s.scheme)
})
for j := 0; j < len(res.hashes[i]); j++ {
tr.Update(res.hashes[i][j][:], res.slots[i][j])
Expand Down

0 comments on commit 18771a7

Please sign in to comment.