Pass loop variable to defer function

The loop variable changes before the defer executes, so we need to
pass it to the function to make sure the closure has the correct
version of the loop variable.
This commit is contained in:
Austin Roberts 2022-01-07 13:54:47 -06:00
parent a88d316b0a
commit 627f95403f

View File

@ -43,7 +43,7 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) {
}
for i := min ; i < num; i++ {
update, ok := freezerUpdates[i]
defer func() { delete(freezerUpdates, i) }()
defer func(i uint64) { delete(freezerUpdates, i) }(i)
if !ok {
log.Warn("Attempting to commit untracked block", "num", i)
continue