axieinfinity / ronin

A DPoS blockchain.
GNU Lesser General Public License v3.0
67 stars 30 forks source link

eth/protocols/snap: fix batch writer when resuming an aborted sync (#… #587

Closed huyngopt1994 closed 4 weeks ago

huyngopt1994 commented 4 weeks ago

https://go.dev/blog/loopvar-preview, in path-base-implementing, we will use the callback function when generating a trie for per task which triggers this issue

    task.genTrie = trie.NewStackTrie(func(owner common.Hash, path []byte, hash common.Hash, val []byte) {
                    rawdb.WriteTrieNode(task.genBatch, owner, path, hash, val, s.scheme)
                })