Fix pool giving too many entries (#488)

This commit is contained in:
Giulio rebuffo 2022-06-13 10:00:31 +02:00 committed by GitHub
parent 6cad65e62b
commit dba877998b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -611,7 +611,8 @@ func (p *TxPool) Best(n uint16, txs *types.TxsRlp, tx kv.Tx) error {
txs.Resize(uint(cmp.Min(int(n), len(p.pending.best.ms)))) txs.Resize(uint(cmp.Min(int(n), len(p.pending.best.ms))))
best := p.pending.best best := p.pending.best
for i, j := 0, 0; j < int(n) && i < len(best.ms); i++ { j := 0
for i := 0; j < int(n) && i < len(best.ms); i++ {
if best.ms[i].Tx.Gas >= p.blockGasLimit.Load() { if best.ms[i].Tx.Gas >= p.blockGasLimit.Load() {
// Skip transactions with very large gas limit // Skip transactions with very large gas limit
continue continue
@ -628,6 +629,7 @@ func (p *TxPool) Best(n uint16, txs *types.TxsRlp, tx kv.Tx) error {
txs.IsLocal[j] = isLocal txs.IsLocal[j] = isLocal
j++ j++
} }
txs.Resize(uint(j))
return nil return nil
} }