Merge pull request #18 from openrelayxyz/develop

Release memory leak fix to master
This commit is contained in:
AusIV 2021-10-29 11:17:34 -05:00 committed by GitHub
commit 75b4d1f625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,11 +37,16 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) {
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
if freezerUpdates == nil { freezerUpdates = make(map[uint64]map[string]interface{}) } if freezerUpdates == nil { freezerUpdates = make(map[uint64]map[string]interface{}) }
defer func() { delete(freezerUpdates, num) }() min := ^uint64(0)
update, ok := freezerUpdates[num] for i := range freezerUpdates{
if min < i { min = i }
}
for i := min ; i < num; i++ {
update, ok := freezerUpdates[i]
defer func() { delete(freezerUpdates, i) }()
if !ok { if !ok {
log.Warn("Attempting to commit untracked block", "num", num) log.Warn("Attempting to commit untracked block", "num", i)
return continue
} }
fnList := pl.Lookup("ModifyAncients", func(item interface{}) bool { fnList := pl.Lookup("ModifyAncients", func(item interface{}) bool {
_, ok := item.(func(uint64, map[string]interface{})) _, ok := item.(func(uint64, map[string]interface{}))
@ -49,7 +54,7 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) {
}) })
for _, fni := range fnList { for _, fni := range fnList {
if fn, ok := fni.(func(uint64, map[string]interface{})); ok { if fn, ok := fni.(func(uint64, map[string]interface{})); ok {
fn(num, update) fn(i, update)
} }
} }
appendAncientFnList := pl.Lookup("AppendAncient", func(item interface{}) bool { appendAncientFnList := pl.Lookup("AppendAncient", func(item interface{}) bool {
@ -107,7 +112,8 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) {
} }
for _, fni := range appendAncientFnList { for _, fni := range appendAncientFnList {
if fn, ok := fni.(func(number uint64, hash, header, body, receipts, td []byte)); ok { if fn, ok := fni.(func(number uint64, hash, header, body, receipts, td []byte)); ok {
fn(num, hash, header, body, receipts, td) fn(i, hash, header, body, receipts, td)
}
} }
} }
} }