mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core/txpool/legacypool: refactor truncatePending
This commit is contained in:
parent
b6bdd698a0
commit
27725c46af
1 changed files with 11 additions and 11 deletions
|
|
@ -1494,22 +1494,22 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
|
||||||
// equal number for all for accounts with many pending transactions.
|
// equal number for all for accounts with many pending transactions.
|
||||||
func (pool *LegacyPool) truncatePending() {
|
func (pool *LegacyPool) truncatePending() {
|
||||||
pending := uint64(0)
|
pending := uint64(0)
|
||||||
for _, list := range pool.pending {
|
|
||||||
pending += uint64(list.Len())
|
// Assemble a spam order to penalize large transactors first
|
||||||
|
spammers := prque.New[uint64, common.Address](nil)
|
||||||
|
for addr, list := range pool.pending {
|
||||||
|
// Only evict transactions from high rollers
|
||||||
|
length := uint64(list.Len())
|
||||||
|
pending += length
|
||||||
|
if length > pool.config.AccountSlots {
|
||||||
|
spammers.Push(addr, uint64(length))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if pending <= pool.config.GlobalSlots {
|
if pending <= pool.config.GlobalSlots {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingBeforeCap := pending
|
pendingBeforeCap := pending
|
||||||
// Assemble a spam order to penalize large transactors first
|
|
||||||
spammers := prque.New[int64, common.Address](nil)
|
|
||||||
for addr, list := range pool.pending {
|
|
||||||
// Only evict transactions from high rollers
|
|
||||||
if uint64(list.Len()) > pool.config.AccountSlots {
|
|
||||||
spammers.Push(addr, int64(list.Len()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Gradually drop transactions from offenders
|
// Gradually drop transactions from offenders
|
||||||
offenders := []common.Address{}
|
offenders := []common.Address{}
|
||||||
for pending > pool.config.GlobalSlots && !spammers.Empty() {
|
for pending > pool.config.GlobalSlots && !spammers.Empty() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue