8000 fix(mempool/lanes): Do not reuse iterator when reaping by hvanz · Pull Request #3996 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(mempool/lanes): Do not reuse iterator when reaping #3996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions mempool/clist_mempool.go
C8D4
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ type CListMempool struct {
defaultLane types.Lane
sortedLanes []types.Lane // lanes sorted by priority, in descending order

reapIter *NonBlockingWRRIterator

// Keep a cache of already-seen txs.
// This reduces the pressure on the proxyApp.
cache TxCache
Expand Down Expand Up @@ -115,7 +113,6 @@ func NewCListMempool(
sort.Slice(mp.sortedLanes, func(i, j int) bool {
return mp.sortedLanes[i] > mp.sortedLanes[j]
})
mp.reapIter = NewWRRIterator(mp)
mp.recheck = newRecheck(NewWRRIterator(mp))

if cfg.CacheSize > 0 {
Expand Down Expand Up @@ -609,9 +606,9 @@ func (mem *CListMempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) types.Txs {
// size per tx, and set the initial capacity based off of that.
// txs := make([]types.Tx, 0, cmtmath.MinInt(mem.Size(), max/mem.avgTxSize))
txs := make([]types.Tx, 0, mem.Size())
mem.reapIter.Reset(mem.lanes)
iter := NewWRRIterator(mem)
for {
memTx := mem.reapIter.Next()
memTx := iter.Next()
if memTx == nil {
break
}
Expand Down Expand Up @@ -649,9 +646,9 @@ func (mem *CListMempool) ReapMaxTxs(max int) types.Txs {
}

txs := make([]types.Tx, 0, cmtmath.MinInt(mem.Size(), max))
mem.reapIter.Reset(mem.lanes)
iter := NewWRRIterator(mem)
for len(txs) <= max {
memTx := mem.reapIter.Next()
memTx := iter.Next()
if memTx == nil {
break
}
Expand Down
Loading
0