mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
core/txpool/blobpool: evict stale transactions from reorg buffer
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
065fa343b8
commit
0e5ae8e438
1 changed files with 4 additions and 1 deletions
|
|
@ -2188,12 +2188,15 @@ func (p *BlobPool) gappedAllowance(addr common.Address) int {
|
||||||
func (p *BlobPool) evictGapped() {
|
func (p *BlobPool) evictGapped() {
|
||||||
cutoff := time.Now().Add(-gappedLifetime)
|
cutoff := time.Now().Add(-gappedLifetime)
|
||||||
for from, txs := range p.gapped {
|
for from, txs := range p.gapped {
|
||||||
|
nonce := p.state.GetNonce(from)
|
||||||
// Reuse the original slice to avoid extra allocations.
|
// Reuse the original slice to avoid extra allocations.
|
||||||
// This is safe because we only keep references to the original gappedTx objects,
|
// This is safe because we only keep references to the original gappedTx objects,
|
||||||
// and we overwrite the slice for this account after filtering.
|
// and we overwrite the slice for this account after filtering.
|
||||||
keep := txs[:0]
|
keep := txs[:0]
|
||||||
for i, gtx := range txs {
|
for i, gtx := range txs {
|
||||||
if gtx.timestamp.Before(cutoff) {
|
if gtx.timestamp.Before(cutoff) || gtx.tx.Nonce() < nonce {
|
||||||
|
// Evict old or stale transactions
|
||||||
|
// Should we add stale to limbo here if it would belong?
|
||||||
delete(p.gappedSource, gtx.tx.Hash())
|
delete(p.gappedSource, gtx.tx.Hash())
|
||||||
txs[i] = nil // Explicitly nil out evicted element
|
txs[i] = nil // Explicitly nil out evicted element
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue