Commit f7cef711 authored by Michael de Hoog's avatar Michael de Hoog Committed by GitHub

[Batcher] Fix memory leak, reverse prepended blocks (#12874)

* Don't prepend blocks in reverse order

* Fix memory leak
parent 6ea4e40b
...@@ -118,8 +118,11 @@ func (s *channelManager) TxConfirmed(_id txID, inclusionBlock eth.BlockID) { ...@@ -118,8 +118,11 @@ func (s *channelManager) TxConfirmed(_id txID, inclusionBlock eth.BlockID) {
delete(s.txChannels, id) delete(s.txChannels, id)
done, blocksToRequeue := channel.TxConfirmed(id, inclusionBlock) done, blocksToRequeue := channel.TxConfirmed(id, inclusionBlock)
if done { if done {
s.removePendingChannel(channel)
if len(blocksToRequeue) > 0 {
s.blocks.Prepend(blocksToRequeue...)
}
for _, b := range blocksToRequeue { for _, b := range blocksToRequeue {
s.blocks.Prepend(b)
s.metr.RecordL2BlockInPendingQueue(b) s.metr.RecordL2BlockInPendingQueue(b)
} }
} }
...@@ -505,8 +508,8 @@ func (s *channelManager) Requeue(newCfg ChannelConfig) { ...@@ -505,8 +508,8 @@ func (s *channelManager) Requeue(newCfg ChannelConfig) {
} }
// We put the blocks back at the front of the queue: // We put the blocks back at the front of the queue:
s.blocks.Prepend(blocksToRequeue...)
for _, b := range blocksToRequeue { for _, b := range blocksToRequeue {
s.blocks.Prepend(b)
s.metr.RecordL2BlockInPendingQueue(b) s.metr.RecordL2BlockInPendingQueue(b)
} }
......
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